c++ - GCC 中包含文件的更详细模式

标签 c++ gcc debian log4cplus

我正在尝试编译其他人的项目。我已经设法在 Windows 下构建它,这意味着它是可编译的,但现在我在 Linux 上苦苦挣扎。具体来说,我收到一个文件的错误:

#ifndef _LOGGER_H_2011_27_02_ 
#define _LOGGER_H_2011_27_02_ 

//  logger
#include <log4cplus/logger.h>
#include <iomanip>

#define LOG_TRACE(logger, msg) LOG4CPLUS_TRACE(logger, \
    "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

#define LOG_DEBUG(logger, msg) LOG4CPLUS_DEBUG(logger, \
    "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

// I erased repetitive declarations for WARN, FATAl etc...

代码本身对我来说毫无意义,表达式 "[@" <<有点疯狂,但没关系,它应该编译。我得到的错误是:

source/repository/../query/../loader/../common/logger.h:30:64: error: ‘LOG4CPLUS_ERROR’ was not declared in this scope
     "[@" << std::hex << (size_t)this << "] " << std::dec << msg);

还有:

source/repository/Repository.cpp: In member function ‘void W3TTServer::Repository::cleanupSessions()’:
source/repository/Repository.cpp:82:64: error: invalid operands of types ‘const char [33]’ and ‘long int’ to binary ‘operator<<’
  LOG4CPLUS_TRACE(logger, "Cleaning up inactive sessions..." << sessionCleanupTimer);

我启用了详细模式,但这是个玩笑,真的,我得到的只是包含目录的列表:

#include <...> search starts here:
 /usr/local/ssl/include
 /usr/include/c++/4.9
 /usr/include/x86_64-linux-gnu/c++/4.9
 /usr/include/c++/4.9/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

log4cplus 库安装在 /usr/include/log4cplus/ 中由于没有关于缺少头文件的错误,我假设 <log4cplus/logger.h>加载就好了。为了验证这一点,我需要一个包含文件的列表来查看位置是否正确。

如何获得 GCC 中包含的文件列表?

最佳答案

传递 -H (preprocessor) optiong++,通常是将其添加到您的 Makefile 中,例如添加

CXXFLAGS += -H

在你的 Makefile 的适当位置

您可以简单地在终端上尝试 make CXX='g++ -H -Wall'

如果您在终端中输入 g++,请在其后添加 -H

关于c++ - GCC 中包含文件的更详细模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32839846/

相关文章:

PYTHONPATH 被忽略

python - C 中的声明考虑了 C++ 中的定义

适用于 Windows 的 Jupyter Notebook 上的 C++

c++ - ROS_INFO_STREAM 不打印

c++ - 我找不到 qt-creator 应该制作的 .exe 文件

c++ - 特别是在 GNU/Linux 环境/工具链中的预编译头文件的优缺点是什么?

c - gcc 编译的 main() 中无用序言的动机,禁用它?

c++ - mupdf - 错误的宏

linux - 将 linux box 配置为具有静态 ip

debian - 有没有人有 'hello world' Debian 软件包,用于 D 源代码?