[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [LI] C Programming problem



Umesh Kumar Sisodia forced the electrons to say:
> 
> In the manual of putc() it is written that putc & putchar may be a macro
> depending on the compile time definition.
> 	Can anyone clarify in which cases it is a macro.

Unless you explicitly tell the compiler to use the function versions
of these, these maybe macros. Then also, your stdio library should also
have function implementations of these.

The ANSI standard allows these to be macros.

To use the function versions of these, your code should look like:

#ifdef putchar
#undef putchar
#endif

/* ... */

putchar (c);

/* ... */

The only one guaranteed to be not a macro is fputc().

> 
> Is there any book explaining the internals of standard I/O library.

Kernighan and Ritchie 2nd edition has one full chapter dedicated to the
standard library. The libc docs are also excellent. Try info libc.

Binand

-- 
#include <stdio.h>                                   | Binand Raj S.
char *p = "#include <stdio.h>%cchar *p = %c%s%c;     | This is a self-
int main(){printf(p,10,34,p,34,10);return 0;}%c";    | printing program.
int main(){printf(p,10,34,p,34,10);return 0;}        | Try it!!
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.