简体   繁体   中英

How to apply C++ preprocessor to a C++ header file on Ubuntu

I tried to apply preprocessor to a C++ header file with Macros using the below command.

$ g++ -E heap.h 

And I wasn't able to get the preprocessed header file, because preprocessing was finished with the below error.

...
...
# 9 "heap.h" 2
heap.h:10:28: fatal error: src/allocation.h: No such file or directory

To tell g++ about the directories that includes header file included in heap.h, I typed the below command, but it showed the same error.

$ g++ -E heap.h -I .
...
...
heap.h:10:28: fatal error: src/allocation.h: No such file or directory

Can you leave the solution of this problem if you have an experience that you solve this problem?

The steps:

  1. You may need to change to the directory from where your build system invokes the command if the command does not use absolute paths.
  2. Copy the compiler command line from your make/cmake/etc. output.
  3. Add -E switch.
  4. Add/change -o parameter to <source>.i .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM