Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 包含单个boost posix_time.hpp头时发生编译错误_C++_Gcc_Boost_Boost Date Time - Fatal编程技术网

C++ 包含单个boost posix_time.hpp头时发生编译错误

C++ 包含单个boost posix_time.hpp头时发生编译错误,c++,gcc,boost,boost-date-time,C++,Gcc,Boost,Boost Date Time,我遇到了一个与Boost相关的似乎无法穿透的编译错误,我将其简化为包含一个Boost头文件。在编译(Mac OS X 10.6.8上的GCC 4.2)时,仅包含以下内容的空文件包括: #include "boost/date_time/posix_time/posix_time.hpp" …生成以下错误: In file included from ../../../Boost Libraries/Boost_1_55_0/boost/type_traits/has_left_shift.h

我遇到了一个与Boost相关的似乎无法穿透的编译错误,我将其简化为包含一个Boost头文件。在编译(Mac OS X 10.6.8上的GCC 4.2)时,仅包含以下内容的空文件包括:

#include "boost/date_time/posix_time/posix_time.hpp"
…生成以下错误:

 In file included from ../../../Boost Libraries/Boost_1_55_0/boost/type_traits/has_left_shift.hpp:43,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/lexical_cast.hpp:165,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/string_parse_tree.hpp:13,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/period_parser.hpp:14,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/date_facet.hpp:23,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/gregorian/gregorian_io.hpp:16,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/gregorian/gregorian.hpp:31,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_formatters.hpp:12,
                 from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/posix_time.hpp:24,
                 from /Users/homedir/dev/TheProject/Mac/Xcode/../Source/feature/test.cpp:12:
../../../Boost Libraries/Boost_1_55_0/boost/type_traits/detail/has_binary_operator.hpp:155: error: expected unqualified-id before 'do'
In file included from ../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/posix_time.hpp:34,
                 from /Users/homedir/dev/TheProject/Mac/Xcode/../Source/feature/test.cpp:12:
../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_parsers.hpp:40: error: expected `}' at end of input
../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_parsers.hpp:40: error: expected unqualified-id at end of input
../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_parsers.hpp:40: error: expected `}' at end of input
../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_parsers.hpp:40: error: expected `}' at end of input
../../../Boost Libraries/Boost_1_55_0/boost/date_time/posix_time/time_parsers.hpp:40: error: expected `}' at end of input
这些Boost库被用作“仅标题”——未构建


有什么线索吗?

问题出在文件
中,不知怎的,它被包含了进去

它定义了一个名为
check
(和另一个名为
require
)的宏,该宏与“boost/type\u traits/detail/has\u binary\u operator.hpp”中名为
check
的函数冲突

您可以定义
\uuuuu资产宏\uuuuu
以防止发生这种情况


FWIW,在Mac OS X 10.7及更高版本中,苹果将这些宏重命名为
\uu check
等,以防止出现此问题。

我假设您指的是编译器集合中的GCC,而不是二进制,只是以防万一:您使用什么命令进行编译?你使用的是<代码> C++ >代码>还是<代码> G++<代码>,或者你真的使用<代码> GCC < /代码>?XCODE正在生成:/Deave/Up/BI/GCC-4.2-X-C++(加上所有其他选项、路径等),我怀疑这个库不喜欢GCC 4.2。(毕竟它很老)@BillyONeal——根据Boost日期时间库文档:“以下编译器完全支持库的所有方面:GCC 3.3,4.x关于达尔文”…——你是100%正确的。“不知何故”,10.5SDK的CarbonCore.framework包含debug.h,而debug.h又包含AssertMacros.h。是的,定义ASSERTMACROS可以解决上述问题。这样做还有什么副作用?定义
\uu ASSERTMACROS\uu
有效地防止
被包含,因为这是它用作“包含保护”的东西。副作用是,您不能使用该文件中定义的任何宏(您可能根本没有使用这些宏)。