cpp: How to compute dependencies of a header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I need to compute the file dependencies for C++ source and header
files. Using the -MM option of gcc, here is how I proceed today:

For example, if I need to get the dependencies for main.cpp and
main.hpp, I would execute :

  >g++ -x c++ -MM -Iincludepath main.cpp main.hpp
  main.o: main.cpp main.hpp includepath/include2.hpp
  main.o: main.hpp includepath/include2.hpp

I then parse the output to get my result with minimal effort (I ignore
the .o file, and the remainder of the line is simply the original
source file followed by the list of its dependencies).

My problem is that the -MM option of gcc is not meant to be used with
header files, and seems to choke on header-only pragmas such as
"#pragma once". I have been looking at an option to ignore pragmas,
with no success.

Could anyone either provide me with a way to ignore unwanted pragmas,
or else with a idea on how to achieve the desired result?

Thanks a lot in advance. CC'ing me in the reply would be very much
appreciated. Since this is the first time I post on that list, please
redirect me to a more appropriate list if needed.
Best regards,
--
Remi Delmas



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux