Standard Library macros

R

Raj Pashwar

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
 
B

Ben Pfaff

Raj Pashwar said:
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?
 
B

Ben Bacarisse

Raj Pashwar said:
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).
 
N

Nobody

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top