Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #23400 > unrolled thread

Standard Library macros

Started byRaj Pashwar <raj121190@hotmail.NOSPAM.com>
First post2012-07-19 17:41 +0000
Last post2012-07-20 07:55 +0100
Articles 4 — 4 participants

Back to article view | Back to comp.lang.c


Contents

  Standard Library macros Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2012-07-19 17:41 +0000
    Re: Standard Library macros Ben Pfaff <blp@cs.stanford.edu> - 2012-07-19 10:46 -0700
    Re: Standard Library macros Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-19 21:35 +0100
    Re: Standard Library macros Nobody <nobody@nowhere.com> - 2012-07-20 07:55 +0100

#23400 — Standard Library macros

FromRaj Pashwar <raj121190@hotmail.NOSPAM.com>
Date2012-07-19 17:41 +0000
SubjectStandard Library macros
Message-ID<ju9gsq$5s0$1@speranza.aioe.org>
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

[toc] | [next] | [standalone]


#23401

FromBen Pfaff <blp@cs.stanford.edu>
Date2012-07-19 10:46 -0700
Message-ID<878vefhces.fsf@blp.benpfaff.org>
In reply to#23400
Raj Pashwar <raj121190@hotmail.NOSPAM.com> 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?

[toc] | [prev] | [next] | [standalone]


#23404

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-07-19 21:35 +0100
Message-ID<0.0598ebe23ac94ec9fd8c.20120719213538BST.87wr1zbiat.fsf@bsb.me.uk>
In reply to#23400
Raj Pashwar <raj121190@hotmail.NOSPAM.com> 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.

[toc] | [prev] | [next] | [standalone]


#23425

FromNobody <nobody@nowhere.com>
Date2012-07-20 07:55 +0100
Message-ID<pan.2012.07.20.06.55.00.549000@nowhere.com>
In reply to#23400
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web