Re: some "newbie" questions

From: Alexander Bartolich (alexander.bartolich_at_gmx.at)
Date: 12/23/03


Date: 23 Dec 2003 00:55:49 GMT

begin followup to Les Cargill:
> Sean Kenwrick wrote:
>> You will never find a compiler that will complain about this
>> since the compiler knows nothing about what the format specifiers
>> mean in the printf() function.
>
> gcc does, just not in this case. It makes a special exception for
> printf, since the standard(s) refer(s) to it.

Just a minor nitpicking: The function name is not hard-wired into
gcc. The whole thing relies on cooperation by the header file.

# The `format' attribute specifies that a function takes `printf',
# `scanf', `strftime' or `strfmon' style arguments which should be
# type-checked against a format string. For example, the
# declaration:
#
# extern int
# my_printf (void *my_object, const char *my_format, ...)
# __attribute__ ((format (printf, 2, 3)));
#
# causes the compiler to check the arguments in calls to `my_printf'
# for consistency with the `printf' style format string argument
# `my_format'.

-- 
Für Google, Tux und GPL!


Relevant Pages

  • Re: LDBL_MAX -1.#QNAN0e+000 with MinGW?
    ... What compilers don't support long double in printf()? ... Microsoft doesn't support long double precision, ... compiler system it is equal to double precision. ... to adapt gcc to the run time library) that means that the ...
    (comp.lang.c)
  • Re: Behavior of the code
    ... What is surprising is that the gcc printf recognizes somehow hh, ... The GNU compiler collection contains a "C compiler" ... Support for hh was added in glibc 2.1. ...
    (comp.lang.c)
  • Re: x86 Stack Confusion
    ... There is nothing analogous to printf() with it's ... > compiler to generate code based on the actual argument types. ... > the design decisions that went into C. C implements its I/O functions ... the format string, and uses the full printf where needed. ...
    (comp.lang.c)
  • Re: How does the compiler do with this code?
    ... int printf(const char * restrict format, ... to assume the first argument is a format string. ... might, depending on the compiler, allow the compiler to catch ... prototype, then the arguments are passed as is to the printf ...
    (comp.os.linux.development.apps)
  • Re: puzzle in C
    ... printf() the format string "%d, a+b" but you didn't give it a value to ... Since your format string includes %d the printffunction ... Arguments to functions are conventionally passed on the stack. ... differently depending on your compiler, ...
    (comp.lang.c)