这些是我在尝试使用我正在构建的项目时遇到的新错误,该项目使用 Boost 作为静态链接库。但非常包括在汇编中独自哭泣。请指教。
boost 版本:1.68
Visual Studio 版本(社区):15.8.0,最后更新于 2018 年 8 月 14 日。
Severity Code Description Project File Line Suppression State
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 119
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 119
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 119
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 30
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 119
Error C4643 Forward declaring 'allocator' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 30
Error C4643 Forward declaring 'allocator_arg_t' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 49
Error C4643 Forward declaring 'allocator_arg_t' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 49
Error C4643 Forward declaring 'basic_istream' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 47
Error C4643 Forward declaring 'basic_istream' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 47
Error C4643 Forward declaring 'basic_ostream' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 44
Error C4643 Forward declaring 'basic_ostream' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 44
Error C4643 Forward declaring 'basic_string' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 120
Error C4643 Forward declaring 'basic_string' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 120
Error C4643 Forward declaring 'basic_string' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 120
Error C4643 Forward declaring 'basic_string' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 120
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 33
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 33
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 43
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 30
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 33
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 33
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 43
Error C4643 Forward declaring 'bidirectional_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 30
Error C4643 Forward declaring 'bitset' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 143
Error C4643 Forward declaring 'bitset' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 143
Error C4643 Forward declaring 'bitset' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 143
Error C4643 Forward declaring 'bitset' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 143
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 122
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 122
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 122
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 39
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 34
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 122
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\container\detail\std_fwd.hpp 39
Error C4643 Forward declaring 'char_traits' in namespace std is not permitted by the C++ Standard.boost-root\boost\interprocess\detail\std_fwd.hpp 34
Error C4643 Forward declaring 'complex' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 127
Error C4643 Forward declaring 'complex' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 127
Error C4643 Forward declaring 'complex' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 127
Error C4643 Forward declaring 'complex' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 127
Error C4643 Forward declaring 'deque' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 131
Error C4643 Forward declaring 'deque' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 131
Error C4643 Forward declaring 'deque' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 131
Error C4643 Forward declaring 'deque' in namespace std is not permitted by the C++ Standard.boost-root\boost\detail\container_fwd.hpp 131
Error C4643 Forward declaring 'forward_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 32
Error C4643 Forward declaring 'forward_iterator_tag' in namespace std is not permitted by the C++ Standard.boost-root\boost\move\detail\iterator_traits.hpp 32
最佳答案
确实很遗憾......现在看看这个:
Bug fixes and behavior changes in Visual Studio 2017 version 15.8
...
forward declarations and definitions in namespace std
The C++ standard doesn't allow a user to add forward declarations or definitions into namespace std. Adding declarations or definitions to namespace std or to a namespace within namespace std now results in undefined behavior.
At some time in the future, Microsoft will move the location where some STL types are defined. When this happens, it will break existing code that adds forward declarations to namespace std. A new warning, C4643, helps identify such source issues. The warning is enabled in /default mode and is off by default. It will impact programs that are compiled with /Wall or /WX
来自 here .
为避免此错误,直到在相关 header 内进行进一步更改以符合要求,请在包含它们之前添加:
#pragma warning( disable : 4643 )
即使对于从虚幻引擎 4 中构建的代码,这也能暂时解决这个问题。
对于常规的 MSVC 编译,无论是手动编译还是从 VS 中编译,请确保您没有使用 /WX
进行编译,因为它会使警告变成错误。
此外,我并不是建议将此作为长期解决方案,但如果您只是想看到它可以恢复并成功构建,您可以禁用 /permissive
15.3 中引入的编译器标志,以帮助强制执行标准一致性。
关于c++ - 新的 VS C++ 更新使 boost forward 声明的代码不可编译!你能做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51863797/