This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc error handling
- From: Andrew Haley <aph at redhat dot com>
- To: Philip Herron <herron dot philip at googlemail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 23 Mar 2009 10:26:46 +0000
- Subject: Re: Gcc error handling
- References: <49C6A962.2040109@googlemail.com>
Philip Herron wrote:
> Hey
>
> This is just a basic question of the internal compliation.
>
> So say you have a small program that prints like this:
>
> char *mystr= "mystring";
> printf("%s\n", mystr);
>
> but if you were to have had
>
> printf("%c\n",mystr);
>
> gcc would throw up a compliation warning:
>
> warning: format %c expects type int, but argument 2 has type char *
>
> Just wondering what kind of gcc macro checks for that something like
>
> printf(const char* fmt, ...)
>
> is there a macro to go through the fmt and va_list of the different
> types. But then its intereasting if you have something like:
>
> int x= 10000000000;
> printf("%i\n", x);
>
> it will also warn me that x is too big to be an int. I guess its marco
> trickery but maby it isnt a macro maby a gcc internal compilation for
> the 2nd case because when running gdb on apps printf goes to a macro a
> check i think cant remember.
It's nothing to do with macros. Have a look in the gcc manual:
http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Function-Attributes.html#index-functions-with-_0040code_007bprintf_007d_002c-_0040code_007bscanf_007d_002c-_0040code_007bstrftime_007d-or-_0040code_007bstrfmon_007d-style-arguments-2111
Andrew.