Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Standard Library macros

Reply
Thread Tools

Standard Library macros

 
 
Raj Pashwar
Guest
Posts: n/a
 
      07-19-2012
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
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      07-19-2012
Raj Pashwar <(E-Mail Removed)> 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?
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      07-19-2012
Raj Pashwar <(E-Mail Removed)> 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.
 
Reply With Quote
 
Nobody
Guest
Posts: n/a
 
      07-20-2012
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
standard library headers without excessive macros K4 Monk C Programming 3 03-03-2011 05:23 AM
Standard library macros sandeep C Programming 24 12-04-2010 10:53 PM
Explanation of macros; Haskell macros mike420@ziplip.com Python 80 11-07-2003 02:22 AM
Re: Explanation of macros; Haskell macros mike420@ziplip.com Python 5 11-01-2003 01:09 AM
Re: Explanation of macros; Haskell macros mike420@ziplip.com Python 1 10-07-2003 04:07 PM



Advertisments