Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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++ VC++;2008年boost编译问题_C++_Visual Studio 2008_Boost_Compiler Errors - Fatal编程技术网

C++ VC++;2008年boost编译问题

C++ VC++;2008年boost编译问题,c++,visual-studio-2008,boost,compiler-errors,C++,Visual Studio 2008,Boost,Compiler Errors,突然,一个两个项目的解决方案开始无法编译。我不记得做过任何可能影响构建的更改。一个项目是lib,另一个是exe。库仍在编译,没有问题,但exe失败。我在加载一些boost文件时隔离了这个问题。下面是stdafx.cpp中的一个示例,足以显示错误: #include "stdafx.h" #include <boost/thread.hpp> #包括“stdafx.h” #包括 以下是报告的错误: 1>Compiling... 1>stdafx.cpp 1>

突然,一个两个项目的解决方案开始无法编译。我不记得做过任何可能影响构建的更改。一个项目是lib,另一个是exe。库仍在编译,没有问题,但exe失败。我在加载一些boost文件时隔离了这个问题。下面是stdafx.cpp中的一个示例,足以显示错误:

#include "stdafx.h"
#include <boost/thread.hpp>
#包括“stdafx.h”
#包括
以下是报告的错误:

1>Compiling...
1>stdafx.cpp
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdlib.h(525) : see declaration of '_ultoa'
1>c:\libs\boost_1_44_0\boost\mpl\size_t_fwd.hpp(23) : error C2143: syntax error : missing ',' before 'constant'
1>c:\libs\boost_1_44_0\boost\mpl\aux_\integral_wrapper.hpp(42) : error C2143: syntax error : missing ',' before 'constant'
1>c:\libs\boost_1_44_0\boost\mpl\aux_\integral_wrapper.hpp(84) : error C2143: syntax error : missing ',' before 'constant'
1>c:\libs\boost_1_44_0\boost\mpl\aux_\integral_wrapper.hpp(84) : error C3211: 'boost::mpl::size_t<__formal>::value' : explicit specialization is using partial specialization syntax, use template <> instead
1>        with
1>        [
1>            __formal=1135
1>        ]
1>        c:\libs\boost_1_44_0\boost\mpl\aux_\integral_wrapper.hpp(45) : see declaration of 'boost::mpl::size_t<__formal>::value'
1>        with
1>        [
1>            __formal=1135
1>        ]
1>编译。。。
1> stdafx.cpp
1> c:\ProgramFiles(x86)\microsoft visual studio 9.0\vc\include\stdlib.h(525):请参见“ultoa”的声明
1> c:\libs\boost\u 1\u 44\u 0\boost\mpl\size\u t\u fwd.hpp(23):错误C2143:语法错误:缺少“,”在“常量”之前
1> c:\libs\boost\u 1\u 44\u 0\boost\mpl\aux\uu\integral\u wrapper.hpp(42):错误C2143:语法错误:缺少“,”在“常量”之前
1> c:\libs\boost\u 1\u 44\u 0\boost\mpl\aux\uuu\integral\u wrapper.hpp(84):错误C2143:语法错误:缺少“,”在“常量”之前
1> c:\libs\boost\u 1\u 44\u 0\boost\mpl\aux\uu\integral\u wrapper.hpp(84):错误C3211:“boost::mpl::size\u t::value”:显式专门化使用部分专门化语法,请改用模板
1> 与
1>        [
1> 正式=1135
1>        ]
1> c:\libs\boost\u 1\u 44\u 0\boost\mpl\aux\uu\integral\u wrapper.hpp(45):参见“boost::mpl::size\u t::value”的声明
1> 与
1>        [
1> 正式=1135
1>        ]
我注意到,如果我将include行更改为:

#include "stdafx.h"
#include <boost/thread/thread.hpp>
#包括“stdafx.h”
#包括
它是有效的,但我在代码中还有其他包含:

#include <boost/bind.hpp>
#include <boost/function.hpp>
#包括
#包括
它们也给出了相同的4条误差线


有人知道会出什么问题吗?我重申,这段代码工作了几个月,昨天第一次出现错误。

很难猜测,但我认为stdafx.h中定义的某些宏可能与Boost冲突(即Boost使用与宏同名的变量/函数/模板/任何东西)。请记住,宏跨越多个作用域。快速检查-如果更改包含顺序,问题是否会消失?

谢谢Charlie,你说得对,我找到了问题所在。这是资源昨天的一个定义线,它在错误地定义了新的资源ID的同时到达了。这是我花费了几乎两天的头痛的线:{定义n1135-是,即C++包含的系统:(这在windows.h标头及其最小/最大宏中经常发生。
stdafx.h
是包含boost标头的正确位置,常见规则是在预编译标头中包含所有很少修改或从未修改过的标头。首先我包含winapi内容,然后是STL,然后是boost,然后是其他。这可以简化此类问题的检测