C++11 为什么在GCC 5.1中使用前向声明的std::string时u u VA_uargs___; variable宏扩展会崩溃? 包含在文件中。/../folly/FBString.h:59:0, from./../folly/Conv.h:27, 来自detail/cacheLocation.cpp:23: ../../folly/Traits.h:155:38:错误:模板参数1无效 结构是可扩展的:std::true\u type{}; ^ ./../folly/Traits.h:221:3:注意:在宏“folly\u假设\u可重新定位”的扩展中 愚蠢假设可重新定位(uuu VA_uargs)}\ ^ ./../folly/Traits.h:427:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 3”的展开中 愚蠢假设向量兼容3(标准::基本字符串); ^ ../../folly/Traits.h:171:48:错误:模板参数1无效 结构具有\u nothrow\u构造函数::boost::true\u type{}; ^ ../../folly/Traits.h:224:5:注意:在宏'folly'的展开中,假设\u具有\u NOTHROW\u构造函数' 愚蠢的假设没有构造函数(uu VA_ARGS_uu)} ^ ./../folly/Traits.h:427:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 3”的展开中 愚蠢假设向量兼容3(标准::基本字符串); ^ ../../folly/Traits.h:155:38:错误:模板参数1无效 结构是可扩展的:std::true\u type{}; ^ ./../folly/Traits.h:213:3:注意:在宏“folly\u假设\u可重新定位”的扩展中 愚蠢假设可重新定位(uuu VA_uargs)}\ ^ ./../folly/Traits.h:429:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 2”的展开中 愚蠢假设向量兼容2(标准::列表); ^ ../../folly/Traits.h:171:48:错误:模板参数1无效 结构具有\u nothrow\u构造函数::boost::true\u type{}; ^ ../../folly/Traits.h:216:5:注意:在宏'folly'的展开中,假设\u具有\u NOTHROW\u构造函数' 愚蠢的假设没有构造函数(uu VA_ARGS_uu)} ^ ./../folly/Traits.h:429:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 2”的展开中 愚蠢假设向量兼容2(标准::列表); ^ Makefile:1395:目标“detail/cacheLocation.lo”的配方失败

C++11 为什么在GCC 5.1中使用前向声明的std::string时u u VA_uargs___; variable宏扩展会崩溃? 包含在文件中。/../folly/FBString.h:59:0, from./../folly/Conv.h:27, 来自detail/cacheLocation.cpp:23: ../../folly/Traits.h:155:38:错误:模板参数1无效 结构是可扩展的:std::true\u type{}; ^ ./../folly/Traits.h:221:3:注意:在宏“folly\u假设\u可重新定位”的扩展中 愚蠢假设可重新定位(uuu VA_uargs)}\ ^ ./../folly/Traits.h:427:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 3”的展开中 愚蠢假设向量兼容3(标准::基本字符串); ^ ../../folly/Traits.h:171:48:错误:模板参数1无效 结构具有\u nothrow\u构造函数::boost::true\u type{}; ^ ../../folly/Traits.h:224:5:注意:在宏'folly'的展开中,假设\u具有\u NOTHROW\u构造函数' 愚蠢的假设没有构造函数(uu VA_ARGS_uu)} ^ ./../folly/Traits.h:427:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 3”的展开中 愚蠢假设向量兼容3(标准::基本字符串); ^ ../../folly/Traits.h:155:38:错误:模板参数1无效 结构是可扩展的:std::true\u type{}; ^ ./../folly/Traits.h:213:3:注意:在宏“folly\u假设\u可重新定位”的扩展中 愚蠢假设可重新定位(uuu VA_uargs)}\ ^ ./../folly/Traits.h:429:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 2”的展开中 愚蠢假设向量兼容2(标准::列表); ^ ../../folly/Traits.h:171:48:错误:模板参数1无效 结构具有\u nothrow\u构造函数::boost::true\u type{}; ^ ../../folly/Traits.h:216:5:注意:在宏'folly'的展开中,假设\u具有\u NOTHROW\u构造函数' 愚蠢的假设没有构造函数(uu VA_ARGS_uu)} ^ ./../folly/Traits.h:429:1:注意:在宏“folly\u假设\u FBVECTOR\u兼容\u 2”的展开中 愚蠢假设向量兼容2(标准::列表); ^ Makefile:1395:目标“detail/cacheLocation.lo”的配方失败,c++11,gcc,C++11,Gcc,对我来说,这看起来不错,但编译器会抱怨。所以上面的代码足够简单。作为参考,folly是一种可以查找的开放源代码,它位于以下位置: 核心问题是gcc声称“std::string”含糊不清 然而这听起来很疯狂,对吧。。。代码对std::string进行了正向声明,但是双abi 98/11 libstdc++通过内联名称空间将std::string转换为std:u cx11::string。因此,在“非内联命名空间从用户空间向前声明”之后,gcc开始将std::string视为模棱两可。很明显,这是

对我来说,这看起来不错,但编译器会抱怨。

所以上面的代码足够简单。作为参考,folly是一种可以查找的开放源代码,它位于以下位置:

核心问题是gcc声称“std::string”含糊不清


然而这听起来很疯狂,对吧。。。代码对std::string进行了正向声明,但是双abi 98/11 libstdc++通过内联名称空间将std::string转换为std:u cx11::string。因此,在“非内联命名空间从用户空间向前声明”之后,gcc开始将std::string视为模棱两可。很明显,这是一种不正确的行为,我们不应该转发declare std::string或任何std::之类的东西。

让我进入您的系统,输入
/。/folly
并检查代码。看起来不错的“这”是什么?您的“问题”中只包含大量错误消息。如果看起来不错,那么请保持原样,您将继续得到这些错误。添加详细信息作为答案。。。。。
In file included from ./../folly/FBString.h:59:0,
                 from ./../folly/Conv.h:27,
                 from detail/CacheLocality.cpp:23:
./../folly/Traits.h:155:38: error: template argument 1 is invalid
   struct IsRelocatable<  __VA_ARGS__ > : std::true_type {};
                                      ^
./../folly/Traits.h:221:3: note: in expansion of macro 'FOLLY_ASSUME_RELOCATABLE'
   FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2, T3>) }                   \
   ^
./../folly/Traits.h:427:1: note: in expansion of macro 'FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3'
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3(std::basic_string);
 ^
./../folly/Traits.h:171:48: error: template argument 1 is invalid
   struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
                                                ^
./../folly/Traits.h:224:5: note: in expansion of macro 'FOLLY_ASSUME_HAS_NOTHROW_CONSTRUCTOR'
     FOLLY_ASSUME_HAS_NOTHROW_CONSTRUCTOR(__VA_ARGS__<T1, T2, T3>) }
     ^
./../folly/Traits.h:427:1: note: in expansion of macro 'FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3'
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3(std::basic_string);
 ^
./../folly/Traits.h:155:38: error: template argument 1 is invalid
   struct IsRelocatable<  __VA_ARGS__ > : std::true_type {};
                                      ^
./../folly/Traits.h:213:3: note: in expansion of macro 'FOLLY_ASSUME_RELOCATABLE'
   FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2>) }               \
   ^
./../folly/Traits.h:429:1: note: in expansion of macro 'FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2'
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::list);
 ^
./../folly/Traits.h:171:48: error: template argument 1 is invalid
   struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
                                                ^
./../folly/Traits.h:216:5: note: in expansion of macro 'FOLLY_ASSUME_HAS_NOTHROW_CONSTRUCTOR'
     FOLLY_ASSUME_HAS_NOTHROW_CONSTRUCTOR(__VA_ARGS__<T1, T2>) }
     ^
./../folly/Traits.h:429:1: note: in expansion of macro 'FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2'
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(std::list);
 ^
Makefile:1395: recipe for target 'detail/CacheLocality.lo' failed