Find the answer to your Linux question:
Results 1 to 3 of 3
Anyone know to ask g++ to show me source code post macro expansion? I have a #define that doesn't seem to be expanded as I expect. Thanks!...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    2

    Can g++ print macro expansion?

    Anyone know to ask g++ to show me source code post macro expansion? I have a #define that doesn't seem to be expanded as I expect.

    Thanks!

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I think this will do it

    g++ -E filename.cpp

    Actually your probably better using

    g++ -E filename.cpp>testfile

    Then open testfile in an editor
    Last edited by gerard4143; 12-16-2009 at 10:03 PM.
    Make mine Arch Linux

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    From the gcc man page:
    Code:
           -E  Stop after the preprocessing stage; do not run the compiler proper.  The
               output is in the form of preprocessed source code, which is sent to the
               standard output.
    
               Input files which don’t require preprocessing are ignored.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...