public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Preprocessor macros debugging
@ 2006-12-01 19:33 Peter Cech
  2006-12-01 20:03 ` John Love-Jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Cech @ 2006-12-01 19:33 UTC (permalink / raw)
  To: gcc-help

Hi,

I've run into a problem with preprocessor macros. Compilation fails with
a multiple occurrences of this error:

  /scratch/installed/boost-marvin-platform-2.0-mo/include/boost/boost/type_traits/type_with_alignment.hpp:151:9:
  pasting "BOOST_PP_LIST_IS_CONS_" and "(" does not give a valid preprocessing token

Seems like one of the macro arguments got #defined to "" or something
like that. Last time I was able to work around it by shuffling includes,
but this time I'd like to fix it for good.

Is there any tool, switches to cpp or a relatively simple way to alter
cpp sources so I can get a dump of #defined macros? Or anything that
would help me to track the problem down (my program is using multiple
libraries, some of them are templated C++, so there is significant amount
of include files involved).

Thanks in advance for your help!

Peter Cech

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

* Re: Preprocessor macros debugging
  2006-12-01 19:33 Preprocessor macros debugging Peter Cech
@ 2006-12-01 20:03 ` John Love-Jensen
  2006-12-01 21:54   ` Peter Cech
  0 siblings, 1 reply; 3+ messages in thread
From: John Love-Jensen @ 2006-12-01 20:03 UTC (permalink / raw)
  To: Peter Cech, MSX to GCC

Hi Peter,

> Is there any tool, switches to cpp or a relatively simple way to alter
> cpp sources so I can get a dump of #defined macros?

I use this trick:

You can generate a list of the built in defines by doing this:

echo '' | gcc -E -dM -x c - | sort

echo ''   -- for our mock empty source file
gcc       -- our favorite toolchain driver (or g++)
-E        -- preprocess only
-dM       -- display defines
-x c      -- treat as C (or -x C++)
-         -- use stdin as the source file
sort      -- put the defines in more human readable order

You can use that trick with particular #include files to see what the
vestigial #defines are (vestigial because it won't list #undef'd
identifiers).

You can do the same thing for, say, Foo.c by doing this:

gcc -E -dM -x c Foo.c | sort

Using some shell magic, you can eliminate the "empty source" pre-defines
from the remainder of what's introduced (and not #undef'd) in Foo.c.

If you are using C++, use g++ and -x c++.

HTH,
--Eljay

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

* Re: Preprocessor macros debugging
  2006-12-01 20:03 ` John Love-Jensen
@ 2006-12-01 21:54   ` Peter Cech
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Cech @ 2006-12-01 21:54 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: Peter Cech, MSX to GCC

On Fri, Dec 01, 2006 at 14:03:33 -0600, John Love-Jensen wrote:
> Hi Peter,
> 
> > Is there any tool, switches to cpp or a relatively simple way to alter
> > cpp sources so I can get a dump of #defined macros?
> 
> I use this trick:
> 
> You can generate a list of the built in defines by doing this:
> 
> echo '' | gcc -E -dM -x c - | sort
> 
> echo ''   -- for our mock empty source file
> gcc       -- our favorite toolchain driver (or g++)
> -E        -- preprocess only
> -dM       -- display defines
> -x c      -- treat as C (or -x C++)
> -         -- use stdin as the source file
> sort      -- put the defines in more human readable order
> 
> You can use that trick with particular #include files to see what the
> vestigial #defines are (vestigial because it won't list #undef'd
> identifiers).
> 
> You can do the same thing for, say, Foo.c by doing this:
> 
> gcc -E -dM -x c Foo.c | sort
> 
> Using some shell magic, you can eliminate the "empty source" pre-defines
> from the remainder of what's introduced (and not #undef'd) in Foo.c.
> 
> If you are using C++, use g++ and -x c++.

Thanks, it helped me a lot. It turned out that, in one of the libraries,
somebody unconditionally defined __SUNPRO_CC, which tricked boost into
using Borland- and SUNPro-specific macro tricks, even when compiling
with gcc.

Cheers,
Peter

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

end of thread, other threads:[~2006-12-01 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-01 19:33 Preprocessor macros debugging Peter Cech
2006-12-01 20:03 ` John Love-Jensen
2006-12-01 21:54   ` Peter Cech

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).