Standard Library macros

Discussion in 'C Programming' started by Raj Pashwar, Jul 19, 2012.

  1. Raj Pashwar

    Raj Pashwar Guest

    In another thread I was asking about declaring printf() without including
    <stdio.h>.

    I realized that one time this will fail, is when the Platform Library
    uses a macro for printf(). Actually this is quite likely, because printf
    (...) can be expanded to fprintf(stdout,...).

    So I got to thinking. Is there a way to tell (by preference at compile
    time) whether a standard-library identifier, corresponds to a macro?

    Cheers,
    Raj
     
    Raj Pashwar, Jul 19, 2012
    #1
    1. Advertising

  2. Raj Pashwar

    Ben Pfaff Guest

    Raj Pashwar <> writes:

    > So I got to thinking. Is there a way to tell (by preference at compile
    > time) whether a standard-library identifier, corresponds to a macro?


    #ifdef identifier?
     
    Ben Pfaff, Jul 19, 2012
    #2
    1. Advertising

  3. Raj Pashwar <> writes:

    > In another thread I was asking about declaring printf() without including
    > <stdio.h>.
    >
    > I realized that one time this will fail, is when the Platform Library
    > uses a macro for printf().


    An implementation is required to provide a library function even if it
    is also implemented as a function-like macro.

    > Actually this is quite likely, because printf
    > (...) can be expanded to fprintf(stdout,...).
    >
    > So I got to thinking. Is there a way to tell (by preference at compile
    > time) whether a standard-library identifier, corresponds to a macro?


    That's been answered: #ifdef (or #if defined).

    --
    Ben.
     
    Ben Bacarisse, Jul 19, 2012
    #3
  4. Raj Pashwar

    Nobody Guest

    On Thu, 19 Jul 2012 17:41:46 +0000, Raj Pashwar wrote:

    > In another thread I was asking about declaring printf() without including
    > <stdio.h>.
    >
    > I realized that one time this will fail, is when the Platform Library
    > uses a macro for printf(). Actually this is quite likely, because printf
    > (...) can be expanded to fprintf(stdout,...).


    Also, some versions of libintl.h have:

    #define printf libintl_printf

    Simlarly for the other *printf functions.

    The rationale is that libintl's printf functions support POSIX-style
    positional specifiers (e.g. "%1$d"), which are particularly useful if
    you're using libintl to localise format strings.
     
    Nobody, Jul 20, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    80
    Views:
    2,434
    Stephen J. Bevan
    Nov 7, 2003
  2. Replies:
    1
    Views:
    450
    Marco Antoniotti
    Oct 7, 2003
  3. Replies:
    5
    Views:
    498
  4. sandeep

    Standard library macros

    sandeep, Nov 12, 2010, in forum: C Programming
    Replies:
    24
    Views:
    725
    Peter Nilsson
    Dec 4, 2010
  5. K4 Monk
    Replies:
    3
    Views:
    241
    K4 Monk
    Mar 3, 2011
Loading...

Share This Page