public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Preprocessing & #error
@ 2003-12-10  8:03 Alex Vinokur
  2003-12-10 13:20 ` Eljay Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Vinokur @ 2003-12-10  8:03 UTC (permalink / raw)
  To: gcc-help

Here is some code.

====== C code : foo.c : BEGIN ======
#define ITEM1 100
#define ITEM2 200
#if (ITEM1 != ITEM2)
#error BUG : ITEM1 != ITEM2
#endif
====== C code : foo.c : END ========

====== Compilation (Preprocessing) : BEGIN ======

$ gcc -v
[---omitted---]
gcc version 3.3.1 (cygming special)

$ gcc foo.c
foo.c:4:2: #error BUG : ITEM1 != ITEM2

====== Compilation (Preprocessing) : END ========


I would like to get the following output :
$ gcc foo.c
foo.c:4:2: #error BUG : 100 != 200


Is it possible?


   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================







^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preprocessing & #error
  2003-12-10  8:03 Preprocessing & #error Alex Vinokur
@ 2003-12-10 13:20 ` Eljay Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: Eljay Love-Jensen @ 2003-12-10 13:20 UTC (permalink / raw)
  To: Alex Vinokur, gcc-help

Hi Alex,

>Is it possible?

It is POSSIBLE, but you'd have to write your own pre-pre-processor.  (Perhaps in Perl?)

Without doing to that extra-ordinary effort, it isn't possible with the pre-processor.  AFAIK.

Or you could change the line to read...
#error BUG : 100 != 200
...but I presume that defeats the intent of having the token macro-expanded.

You could also modify your GCC to perform macro expansion on the error line.  That may be more effort than writing your own pre-pre-processor (unless you are already familiar with GCC internals).  And you'd have a custom one-off pre-processor in your GCC.

Pre-processor info here <http://www.delorie.com/gnu/docs/gcc/cpp_62.html>.

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-10 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-10  8:03 Preprocessing & #error Alex Vinokur
2003-12-10 13:20 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).