void -> char cast

Conor Williams conor.williams at gmail.com
Fri Jan 10 19:38:25 UTC 2014


this is how we patch a file on UNIX (up to the dollar sign: "will51 at skynet:~$"
is a prompt ("~" is the current (home) directory) ('ls' gives a file
listing, 'diff' gives the differences, '>' writes to a file, and 'patch'
applies the differences (note the  size of exprfa.c at the end)

will51 at skynet:~$ ls -l exprfa.c*
-rw-r--r-- 1 will51 users 4402 2014-01-10 19:29 exprfa.c
-rw-r--r-- 1 will51 users 4410 2014-01-10 19:33 exprfa.c.withMyFix
will51 at skynet:~$ diff exprfa.c.withMyFix exprfa.c
122c122
<   edup = (char *)(*allocate_func) (i+1);
---
>   edup = (*allocate_func) (i+1);
will51 at skynet:~$ diff exprfa.c.withMyFix exprfa.c > exprfa.c.patch
will51 at skynet:~$ patch exprfa.c exprfa.c.patch
patching file exprfa.c
Reversed (or previously applied) patch detected!  Assume -R? [n] y
will51 at skynet:~$ ls -l exprfa.c*
-rw-r--r-- 1 will51 users 4410 2014-01-10 19:34 exprfa.c
-rw-r--r-- 1 will51 users 4402 2014-01-10 19:29 exprfa.c.orig
-rw-r--r-- 1 will51 users   90 2014-01-10 19:33 exprfa.c.patch
-rw-r--r-- 1 will51 users 4410 2014-01-10 19:33 exprfa.c.withMyFix
will51 at skynet:~$



On Fri, Jan 10, 2014 at 7: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