为什么可执行二进制文件包含包含头文件的路径?

时间:2022-08-17 16:53:43

Why does the compiled and linked executable file contain paths of header files included in my source code? I am using the wxWidgets library and compile with Visual Studio 2013 and gcc. What are these header files used for? If it is a compiler option, how can I disable it to avoid this?

为什么编译和链接的可执行文件包含源代码中包含的头文件路径?我正在使用wxWidgets库并使用Visual Studio 2013和gcc进行编译。这些头文件用于什么?如果它是编译器选项,我如何禁用它以避免这种情况?

Build configuration: release, static linking.

构建配置:发布,静态链接。

为什么可执行二进制文件包含包含头文件的路径?

2 个解决方案

#1


6  

wxwidgets has many asserts in its header files (e.g. in wx/string.h as you noticed), all using the wxASSERT macro defined in wx/debug.h In order to disable these, you can #define wxDEBUG_LEVEL 0 prior to including any wxwidget headers.

wxwidgets在其头文件中有很多断言(例如在你注意到的wx / string.h中),都使用wx / debug.h中定义的wxASSERT宏。为了禁用这些,你可以在包含任何wxwidget之前#define wxDEBUG_LEVEL 0头。

#2


13  

There may be several explanations for such strings to appear in the executable file:

可执行文件中可能会出现多种解释:

  • You may have debugging information bundled in the executable for the debugger to use. Use strip to remove that, or do not use the -g compile option. You should also compile with NDEBUG defined to disable debugging code and assertions. It is usually the case for the Release mode, but you may want to double check.
  • 您可能具有捆绑在可执行文件中的调试信息供调试器使用。使用strip删除它,或者不使用-g compile选项。您还应该使用NDEBUG进行编译,以禁用调试代码和断言。发布模式通常是这种情况,但您可能需要仔细检查。
  • Some functions may use __FILE__ for tracing or logging purposes. __FILE__ expands to the source file name at the point of macro expansion, which may be a source or a header file. One such function is assert(): it is actually a macro that expands to a test and some error reporting code that includes the current filename.
  • 某些函数可能使用__FILE__进行跟踪或记录。 __FILE__在宏扩展时扩展为源文件名,可以是源文件或头文件。一个这样的函数是assert():它实际上是一个扩展为测试的宏和一些包含当前文件名的错误报告代码。
  • Some sources may have static source ids in the form of static char arrays to keep track of source code versions. This approach is quite obsolete, but many old sources still have them.
  • 某些源可能具有静态char数组形式的静态源ID,以跟踪源代码版本。这种方法已经相当陈旧,但许多旧资源仍然存在。

Look for such things in the source files or header files whose name appear in the executable and fix the problems.

在源文件或头文件中查找其名称出现在可执行文件中并修复问题的内容。

#1


6  

wxwidgets has many asserts in its header files (e.g. in wx/string.h as you noticed), all using the wxASSERT macro defined in wx/debug.h In order to disable these, you can #define wxDEBUG_LEVEL 0 prior to including any wxwidget headers.

wxwidgets在其头文件中有很多断言(例如在你注意到的wx / string.h中),都使用wx / debug.h中定义的wxASSERT宏。为了禁用这些,你可以在包含任何wxwidget之前#define wxDEBUG_LEVEL 0头。

#2


13  

There may be several explanations for such strings to appear in the executable file:

可执行文件中可能会出现多种解释:

  • You may have debugging information bundled in the executable for the debugger to use. Use strip to remove that, or do not use the -g compile option. You should also compile with NDEBUG defined to disable debugging code and assertions. It is usually the case for the Release mode, but you may want to double check.
  • 您可能具有捆绑在可执行文件中的调试信息供调试器使用。使用strip删除它,或者不使用-g compile选项。您还应该使用NDEBUG进行编译,以禁用调试代码和断言。发布模式通常是这种情况,但您可能需要仔细检查。
  • Some functions may use __FILE__ for tracing or logging purposes. __FILE__ expands to the source file name at the point of macro expansion, which may be a source or a header file. One such function is assert(): it is actually a macro that expands to a test and some error reporting code that includes the current filename.
  • 某些函数可能使用__FILE__进行跟踪或记录。 __FILE__在宏扩展时扩展为源文件名,可以是源文件或头文件。一个这样的函数是assert():它实际上是一个扩展为测试的宏和一些包含当前文件名的错误报告代码。
  • Some sources may have static source ids in the form of static char arrays to keep track of source code versions. This approach is quite obsolete, but many old sources still have them.
  • 某些源可能具有静态char数组形式的静态源ID,以跟踪源代码版本。这种方法已经相当陈旧,但许多旧资源仍然存在。

Look for such things in the source files or header files whose name appear in the executable and fix the problems.

在源文件或头文件中查找其名称出现在可执行文件中并修复问题的内容。