This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gcc error handling


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]