This is a guess; but, I am thinking you are NOT using a C compiler; instead you are likely using a C++ compiler.
Edit: Reason for my guess is that in other places C++ requires casts where C compilers do it without casts.
Edit2: My guess appears to be wrong I even added the option -Wformat to my MinGW C++ Compiler and I can not dup your error.
Tim S.
Originally Posted by
dukester
I've tried that, and although it compiles, I get the same warning:
warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int **’ [-Wformat]
So casting to (void *) makes the warning disappear.
You bet!! Pass arguments by value and by reference ....
Not there yet, but encountered them in Oberon2 etc
Note: tested this code and it compiled with no warnings using MinGW C and C++ Compilers.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
/* int *ptr = NULL; Tried using two stars and still no warning with MinGW GCC or G++*/
int **ptr = NULL;
printf("Here is a pointer: %p\n", &ptr);
return 0;
}
The C++ Compile Command
Code:
mingw32-g++.exe -std=gnu++0x -Wextra -Wall -g -Winvalid-pch -Iv:\SourceCode\OpenSourceCode\Apps\IDEs\CodeBlocks\Projects\testc -c v:\SourceCode\OpenSourceCode\Apps\IDEs\CodeBlocks\Projects\testc\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\testc.exe obj\Debug\main.o
Code:
mingw32-gcc.exe -Wextra -Wall -g -Winvalid-pch -Iv:\SourceCode\OpenSourceCode\Apps\IDEs\CodeBlocks\Projects\testc -c v:\SourceCode\OpenSourceCode\Apps\IDEs\CodeBlocks\Projects\testc\main.c -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\testc.exe obj\Debug\main.o
Output size is 28.36 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)