void -> char cast

Emmanuel Thomé emmanuel.thome at gmail.com
Fri Jan 10 20:34:46 UTC 2014


Interesting attitude.

Believe it or not, the content of your report has been well understood
(despite poor report quality, as has been indicated earlier). However
the issue really is with your apparent misconception that valid C has
to be valid C++. Not.

If your problem is this:

> my c++ code using your gmp libs would not link with your gmp compiled with gcc.

then all that can be said is that the odds are very much pointing at
the fact that there is an issue with your code, or (most likely) with
the way you link the code. It is perfectly possible to link C++ code
with the gmp library. Just use g++ as the linker. (Your mileage may
vary concerning the strictness in the order of the -l command line
options.)

Maybe I'm wrong. Maybe you're hitting a real bug in gmp. Do we have to
guess which error message you get (in linking), for instance ? And
ditto for all the useful information which is listed in the gmp
documentation as consisting the matter of a useful bug report ?

Last thing: you'd be well advised to not misesteem the amount of UNIX
know-how of the subscribers of this list. Oh and maybe the following
error message from patch actually means something, and could even echo
a comment which has been made on your post:
> Reversed (or previously applied) patch detected!  Assume -R? [n] y

Best regards,

E.

On Fri, Jan 10, 2014 at 8:16 PM, Conor Williams
<conor.williams at gmail.com> wrote:
> guys, 3 things:
>
> 1. my c++ code using your gmp libs would not link with your gmp compiled
> with gcc.
>     This is why I had to compile your gmp with g++ (a well respected gnu c++
> compiler)
>     and that is where the couple of messages showed.
> 2. if you increase the verbosity of the gcc compiler (and I am sure, your c
> compiler)
>     these messages also show.
> 3. i have to take issue with the fact that you do not think my bug report is
> not good... patch (one of the UNIX standards)
>      uses diff to apply code patches, and it is a diff that i gave you...
>
> /thanks
>
>
> On Thu, Jan 9, 2014 at 12:47 PM, Emmanuel Thomé <emmanuel.thome at gmail.com>
> wrote:
>>
>> I don't see any good reason for compiling C code with a C++ compiler.
>>
>> While I do agree that being nice to C++ compilers is important in
>> header files, my opinion is that accomodating the needs of C++
>> compilers in the C source files would yield unnecessary noise.
>>
>> E.
>>
>> On Thu, Jan 9, 2014 at 1:44 PM, Vincent Lefevre <vincent at vinc17.net>
>> wrote:
>> > On 2014-01-09 10:44:46 +0100, Torbjorn Granlund wrote:
>> >> Conor Williams <conor.williams at gmail.com> writes:
>> >>
>> >>   Ubuntu - found when compiling with g++
>> >>
>> >>   will51 at skynet:~/LPS!/lpsb/gmp-5.1.3/demos/expr$ diff exprfa.c
>> >> exprfa.c.orig
>> >>   122c122
>> >>   <   edup = (char *)(*allocate_func) (i+1);
>> >>   ---
>> >>   >   edup = (*allocate_func) (i+1);
>> >>
>> >>
>> >>   will51 at skynet:~/LPS!/lpsb/gmp-5.1.3/demos/expr$ diff exprza.c.orig
>> >> exprza.c
>> >>   51c51
>> >>   <   edup = (*allocate_func) (i+1);
>> >>   ---
>> >>   >   edup = (char *)(*allocate_func) (i+1);
>> >>
>> >> You sent the above to the GMP bug reports mailing list.  Are we to
>> >> interpret it as a bug report?  I just see two patches (one apparently
>> >> backwards) with no explaation for what they are supposed to fix.
>> >
>> > Conor's bug report is not very good, but I think that this is quite
>> > clear: the cast to (char *), needed by C++ compilers, is missing
>> > here, while always present in the source of the library itself.
>> > It seems that the same thing as in mpz/get_str.c[*] (for instance)
>> > should be done.
>> >
>> > [*] mpz/get_str.c, line 70:
>> >       res_str = (char *) (*__gmp_allocate_func) (alloc_size);
>> >
>> > --
>> > Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
>> > 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
>> > Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
>> > _______________________________________________
>> > gmp-bugs mailing list
>> > gmp-bugs at gmplib.org
>> > https://gmplib.org/mailman/listinfo/gmp-bugs
>
>


More information about the gmp-bugs mailing list