Jean-Luc Nacif Coelho Jean-Luc Nacif Coelho - 5 months ago 94
C Question

How to make compiler not show int to void pointer cast warnings

I have some code that does lots of casting from int to void* and vice-versa (i don't care if it's ugly. I like having generic stuff)


typedef struct _List {
long size;
long mSize; // Max size
void** elementArray;

List l;
int i = 2;
l.elementArray[i] = i; // Intentional usage of pointer as integer
// Actual size of pointer does not matter

but when i compile i get a bajillion

warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]

Is there a flag to tell gcc to not print this specific warning?

I'm compiling with -Wall, so I'm not sure if i can make this go away that easilly


apparently just take the flag that the compiler gives you and slap a "no" in front of it does the trick!