不能包含 cliext headers(对于 c++ cli,Visual Studio)

Can't include cliext headers (for c++ cli, Visual Studio)

即使是一个干净的空 dll 项目,它是用 /clr 编译的并且只包含一个 cpp 文件

#include <cliext/vector>

除此之外,编译器喷出

1>------ Build started: Project: test1, Configuration: Debug x64 ------
1>Source.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3331,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3352): message : see reference to class template instantiation 'cliext::BCL_reference<_Cont_t,_Is_ref>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3332,1): error C2805: binary 'operator =' has too few parameters
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3332,1): error C2333: 'cliext::BCL_reference<_Cont_t,_Is_ref>::operator =': error in function declaration; skipping function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3340,1): error C2833: 'operator value_type' is not a recognized operator or type
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3341,1): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3351,1): error C3646: '_Myval': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\iterator(3351,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(872,1): error C2833: 'operator _Mycont_it' is not a recognized operator or type
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1083): message : see reference to class template instantiation 'cliext::impl::vector_base<_Value_t,_Is_ref>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(872,1): error C2059: syntax error: 'newline'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(873,1): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(878,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(878,1): error C2535: 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(856): message : see declaration of 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(883,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(883,1): error C2535: 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(856): message : see declaration of 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(894,1): error C2061: syntax error: identifier '_Myenum_it'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(894,1): error C2535: 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(856): message : see declaration of 'cliext::impl::vector_base<_Value_t,_Is_ref>::vector_base'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(946,1): error C2061: syntax error: identifier 'iterator'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(953,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(960,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(962,1): error C2535: 'void cliext::impl::vector_base<_Value_t,_Is_ref>::_Insert(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(953): message : see declaration of 'cliext::impl::vector_base<_Value_t,_Is_ref>::_Insert'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(971,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(973,1): error C2535: 'void cliext::impl::vector_base<_Value_t,_Is_ref>::_Insert(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(953): message : see declaration of 'cliext::impl::vector_base<_Value_t,_Is_ref>::_Insert'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(991,1): error C3646: 'size_type': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(991,1): error C3646: 'Count_generic': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(992,3): error C2059: syntax error: '{'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(991,1): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1010,1): error C2061: syntax error: identifier '_Myarray_t'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1026,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1038,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1048,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1061,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1072,1): error C2061: syntax error: identifier 'value_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1129,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1149): message : see reference to class template instantiation 'cliext::impl::vector_select<_Value_t,_Is_ref>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1129,1): error C2535: 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1112): message : see declaration of 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1134,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1134,1): error C2535: 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1112): message : see declaration of 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1145,1): error C2061: syntax error: identifier '_Myenum_it'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1145,1): error C2535: 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1112): message : see declaration of 'cliext::impl::vector_select<_Value_t,_Is_ref>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1194,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1306): message : see reference to class template instantiation 'cliext::impl::vector_select<_Value_t,true>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1194,1): error C2535: 'cliext::impl::vector_select<_Value_t,true>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1177): message : see declaration of 'cliext::impl::vector_select<_Value_t,true>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1199,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1199,1): error C2535: 'cliext::impl::vector_select<_Value_t,true>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1177): message : see declaration of 'cliext::impl::vector_select<_Value_t,true>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1210,1): error C2061: syntax error: identifier '_Myenum_it'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1210,1): error C2535: 'cliext::impl::vector_select<_Value_t,true>::vector_select(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1177): message : see declaration of 'cliext::impl::vector_select<_Value_t,true>::vector_select'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1216,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1223,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1224,1): error C2535: 'void cliext::impl::vector_select<_Value_t,true>::resize(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1216): message : see declaration of 'cliext::impl::vector_select<_Value_t,true>::resize'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1229,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1234,1): error C3646: 'value_type': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1234,1): error C3646: 'default': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1234,29): error C2143: syntax error: missing ',' before '['
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1234,1): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1245,1): error C2143: syntax error: missing ')' before ';'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1245,1): error C2059: syntax error: ')'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1245,1): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1291,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1296,1): error C3646: 'insert': unknown override specifier
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1296,17): error C2059: syntax error: '('
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1297,1): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1301,1): error C2061: syntax error: identifier 'iterator'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1363,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1395): message : see reference to class template instantiation 'cliext::vector<_Value_t>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1363,1): error C2535: 'cliext::vector<_Value_t>::vector(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1335): message : see declaration of 'cliext::vector<_Value_t>::vector'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1368,1): error C2061: syntax error: identifier 'size_type'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1368,1): error C2535: 'cliext::vector<_Value_t>::vector(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1335): message : see declaration of 'cliext::vector<_Value_t>::vector'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1379,1): error C2061: syntax error: identifier '_Myenum_it'
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1379,1): error C2535: 'cliext::vector<_Value_t>::vector(void)': member function already defined or declared
1>C:\Program Files (x86)\Microsoft Visual Studio19\Preview\VC\Tools\MSVC.24.28117\include\cliext\vector(1335): message : see declaration of 'cliext::vector<_Value_t>::vector'
1>Done building project "test1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

VS2017、VS2019 和 VS2019 预览版(所有最新版本)都会出现这种情况。我很混乱。这看起来不像是一个错误,因为它相当古老并且经过验证 headers 并且发生在不同的编译器中。

编辑:这里是超级骗子的完整代码(带有项目文件):https://gist.github.com/s9w/a65bf50ed928bd0d6629c1d10b013463

编辑:为了帮助未来遇到同样问题的人:它是 /permissive- 开关(一致性模式)- 不能很好地适应 header。

帮助未来遇到同样问题的人:它是 /permissive- 开关(一致性模式)- 不适合 header。