GCC 中包含文件的更详细模式
More verbose mode for included files in GCC
我正在尝试编译别人的项目。我已经设法在 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) option 传递给 g++
,通常是将其添加到您的 Makefile
中,例如添加
CXXFLAGS += -H
在您 Makefile
的适当位置
您可以直接在终端上尝试 make CXX='g++ -H -Wall'
。
如果您在终端中输入 g++
,请在其后添加 -H
。
我正在尝试编译别人的项目。我已经设法在 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) option 传递给 g++
,通常是将其添加到您的 Makefile
中,例如添加
CXXFLAGS += -H
在您 Makefile
您可以直接在终端上尝试 make CXX='g++ -H -Wall'
。
如果您在终端中输入 g++
,请在其后添加 -H
。