Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What files are actually included when compiling

Tags:

c++

c

gcc

g++

I have a very large code, a lot of which is legacy code. I want to know which of all these files are taking part in the compilation. The code is written in GNU compilers and mostly in C/C++, but some in other programs too. Any advice will be highly appreciated.

Thanks,

Moshe.

I am compiling under linux with a mix of scripts/makefiles. I want to somehow 'wrap' this build with a tool which will give an output of all the source files used in the build, preferably with absolute path names.

What do you say?

like image 257
Moshe Avatar asked Oct 10 '10 15:10

Moshe


People also ask

What are compiler files?

compiled file name extension. The assembly name is generated by the compiler. The . compiled file does not contain executable code. Instead, it contains only the information that ASP.NET needs to find the appropriate assembly.

What happens during compiling?

A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file.


1 Answers

If you want to show included headers then whether that's supported and how to do it depends on the compiler.

E.g.,

C:\test> (g++ --help --verbose 2>&1) | find "header"
  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
  --sysroot=<directory>    Use <directory> as the root directory for headers
  -H                          Print the name of header files as they are used
  -MG                         Treat missing header files as generated files
  -MM                         Like -M but ignore system header files
  -MMD                        Like -MD but ignore system header files
  -MP                         Generate phony targets for all headers
  -Wsystem-headers            Do not suppress warnings from system headers
  -print-objc-runtime-info    Generate C header of platform-specific features
  -ftree-ch                   Enable loop header copying on trees

C:\test> (cl /? 2>&1) | find "include"
/FI<file> name forced include file      /U<name> remove predefined macro
/u remove all predefined macros         /I<dir> add to include search path
/nologo suppress copyright message      /showIncludes show include file names

C:\test> _

In the above you can see the relevant options for respectively g++ and Visual C++.

Cheers & hth.,

– Alf

like image 63
Cheers and hth. - Alf Avatar answered Oct 05 '22 21:10

Cheers and hth. - Alf