I will have to go back and test. But either gcc 4.6, 4.7, 4.8 or 5.0 complained. Only a warning. A similar problem with pthread_create().mvk wrote:There are two issues intermingled in this thread:bob wrote:Some versions have been complaining, which is why I changed it to start with. Not sure what the gcc guys are doing nowadays...mvk wrote:Check if you really need to spell out the explicit (void*) cast to suppress warnings. Normally you can leave that cast implicit if the prototype is known (and when compiling in C mode at least) and keep things a bit more readable.bob wrote:The char * to void * idea is what I had decided to use. Makes it a bit harder to read, however.
You will need an explicit (char*) for arithmetic and be portable.
1. implicit cast to void* (should be fine) and 2. arithmetic on void* as if it were a char* (can be rightfully flagged as an error, as it is a language extension originating from gnu but spread out to more platforms but not all).
Can you be clear about which compiler complains about the first case: implicit cast to void*? I'm not talking about the arithmetic on void*, but about the passing of a non-void* to a properly prototyped function that accepts void* but is given another pointer type. I do the implicit casting in Floyd and other programs and have not heard about compilers complaining (yet) if they are instructed to compile C, and people use a wide variety of them.
From readability point of view it would be a pity if you need two consecutive casts. The need for char* for arithmetic is understandable from the language definition. Sometimes people just blindly add casts until the warnings go away, while it might be better to look at what is happening, maybe rearrange some parenthesis and achieve the same.
Worst case is I can go back to char * until there is a complaint...