Talkback for article: 386, August2005

LF Tip: #defines for writing portable C-code

Back to: http://cgi.linuxfocus.org/English/August2005/article386.shtml

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)gmail.com> [ date: 2006-01-03 ]
nice going~
From: Marty Leisner <leisner(at)rochester.rr.com> [ date: 2006-02-02 ]
This approach is more flexible:

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

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

#ifndef TTY_PORT
#error No tty port defined
#endif

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)indiatimes.com> [ 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 http://cgi.linuxfocus.org/English/August2005/article386.shtml

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

lftalkback version 3.10