Thread: Preprocessing C

  1. #1
    Registered User
    Join Date
    Apr 2002

    Question Preprocessing C

    I need to preprocess some C file, I am using the -P -E options.
    (gcc -P -E *.c). This gives me what I need, but it also gives me TOO MUCH information. I need to get the same output without expanding all of the system include files, I still need the header files from the program I am preprocessing. Is there a way to do this?


  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Hi Trem,

    I am not experiencing the problem you describe with -P -E under gcc version 2.95.3 20010315 (release). What version of gcc are you using? Also, are you using any other command line options?
    Jason Deckard

  3. #3
    Registered User
    Join Date
    Apr 2002
    I am using gcc version 2.96 20000731. I am only using the -P and -E command line options.

    The preprocessed output I am getting is expanding the system header files that I have included in the source and the header files that are included in my applications. I would like to exclude the system header file information from the preprocessed output. I don't think it is possible from the command line.


  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well if you want to just expand #define and #if, but leave all the #include, then you need a couple of additional steps

    1. pre-preprocess the files, to change all the #include lines (only) into something the pre-processor won't touch
    !include "file.h"

    2. pre-process the files as normal

    3. undo step 1 by turning !include back into #include

    This is dead easy in unix/linux with a couple of sed scripts.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. preprocessing
    By ganesh bala in forum C Programming
    Replies: 3
    Last Post: 02-18-2009, 03:24 AM
  2. C preprocessing
    By deepakwar in forum C Programming
    Replies: 7
    Last Post: 11-13-2007, 02:57 AM
  3. Shell command as a preprocessing token
    By hzmonte in forum C Programming
    Replies: 6
    Last Post: 11-01-2005, 07:45 PM
  4. Windows GUI Preprocessing
    By Jaken Veina in forum Windows Programming
    Replies: 5
    Last Post: 07-22-2005, 01:22 PM
  5. Errors in preprocessing.
    By Tronic in forum C++ Programming
    Replies: 17
    Last Post: 03-21-2004, 04:32 PM