Talkback for article: 386, August2005

LF Tip: #defines for writing portable C-code

Back to:

From: BarretJ [ date: 2005-09-15 ]
why not just do this instead?

echo | cpp -dM

cpp defaults to reading standard input, so you don't really need to create an extra file
From: Senthil [ date: 2005-09-23 ]
It was helpful.

From: shen yang <shen.yang888(at)> [ date: 2006-01-03 ]
nice going~
From: Marty Leisner <leisner(at)> [ date: 2006-02-02 ]
This approach is more flexible:

#ifdef sun
#define TTY_PORT "/dev/ttya"

#ifdef linux
#define TTY_PORT "/dev/ttyS0"

#ifndef TTY_PORT
#error No tty port defined

static char *port = TTY_PORT;

The advantages are:
You can define the TTY_PORT on the command line (maybe to port to a new system) -- i.e.:

From: Eric R [ date: 2006-03-08 ]
This one also works

cpp -dM < /dev/null

but the one using echo is shorter.
From: guest [ date: 2006-04-15 ]
I hope someone would write an article regarding "hell of #defines".

Have a look at "openafs" source codes ;)

best regards.
From: Arun <d.arun321(at)> [ date: 2006-05-17 ]
I dont understand why we need to change the timestamp of /tmp/foo.o
From: James [ date: 2006-07-31 ]
Hi Arun,
"touch" does not modify the timestamp in this case. It just
creates an empty file

8 talkbacks

Due to the increased amount of web spam we have deciced to removed the talkback posting possibility. You can read old talkbacks but you can no longer post new ones.

Back to

Please contact webmaster(at) if you have any questions with regards to this talkback

lftalkback version 3.10