Closed ghost closed 11 years ago
Hi I'm not very clear what you mean? could you give me an example?
@hello,
add this flag to your build script -Wpointer-arith
(flag which matters to many folks, especially when dealing with SIMD types and in a greater concern memory alignments and generic pointer arithmetics)
example
/** gcc test.c -Wall -Wpointer-arith **/
#include <stdio.h>
int main (int argc, char **argv)
{
void * bar;
void * foo;
foo = bar + 1;
return 0;
}
/**
test.c: In function ‘main’:
test.c:8: warning: pointer of type ‘void *’ used in arithmetic
**/
Wimplicit-function-declaration
warning is triggered when there is a lack of function prototype declaration, K&R is dead.
example
/** gcc test.c -Wall **/
int main (int argc, char **argv)
{
const char * bar = "hello";
long l = strlen(bar);
void * foo;
foo = bar + 1;
return 0;
}
/**
test.c: In function ‘main’:
test.c:4: warning: implicit declaration of function ‘strlen’
test.c:4: warning: incompatible implicit declaration of built-in function ‘strlen’
test.c:6: warning: assignment discards qualifiers from pointer target type
test.c:4: warning: unused variable ‘l’
**/
let me know,
Cheers!
thanks, I will try it!
ignorance is made of attempts, knowledge is made of acts.
Cheers.
@Hello,
dereferencing and pointer-arithmetic on void pointers is not permitted by the standard since sizeof(void) is undefined, moreover, Wimplicit-function-declaration, please declare your function prototypes or use extern, that's easy.