使用Custom header从Practical Programming 2nd编译代码时出错

时间:2017-01-30 20:49:04

标签: c++ visual-studio

我从PPP2nd的第一个示例开始,我立即遇到了自定义标头的重大问题。我已将头部放在编译器include目录中以便于访问。 VS 2010和2012都无法编译。非常感谢您的帮助。

#include <std_lib_facilities.h>

int main()
{
    cout << "Hello,world\n";
    return 0;
}


Error   1   error C2868: 'std::vector<_Ty,_Alloc>::size_type' : illegal syntax for using-declaration; expected qualified-name   c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 71  1   HelloWorld
Error   2   error C2143: syntax error : missing ';' before '='  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 71  1   HelloWorld
Error   3   error C2238: unexpected token(s) preceding ';'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 71  1   HelloWorld
Error   4   error C2061: syntax error : identifier 'initializer_list'   c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 80  1   HelloWorld
Error   5   error C2535: 'Vector<T>::Vector(void)' : member function already defined or declared    c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 80  1   HelloWorld
Error   6   error C2868: 'std::basic_string<_Elem,_Traits,_Alloc>::size_type' : illegal syntax for using-declaration; expected qualified-name   c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 102 1   HelloWorld
Error   7   error C2143: syntax error : missing ';' before '='  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 102 1   HelloWorld
Error   8   error C2238: unexpected token(s) preceding ';'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 102 1   HelloWorld
Error   9   error C2143: syntax error : missing ';' before '{'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 213 1   HelloWorld
Error   10  error C2275: 'std::uniform_int_distribution<>' : illegal use of this type as an expression  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 213 1   HelloWorld
Error   11  error C2143: syntax error : missing ';' before '}'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 213 1   HelloWorld
Error   12  error C2988: unrecognizable template declaration/definition c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 222 1   HelloWorld
Error   13  error C2059: syntax error : 'using' c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 222 1   HelloWorld
Error   14  error C2143: syntax error : missing ';' before '<'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 243 1   HelloWorld
Error   15  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 243 1   HelloWorld
Error   16  error C2988: unrecognizable template declaration/definition c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 243 1   HelloWorld
Error   17  error C2059: syntax error : '<' c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 243 1   HelloWorld
Error   18  error C2143: syntax error : missing ';' before '{'  c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 251 1   HelloWorld
Error   19  error C2447: '{' : missing function header (old-style formal list?) c:\program files (x86)\microsoft visual studio 11.0\vc\include\std_lib_facilities.h 251 1   HelloWorld
    20  IntelliSense: type name is not allowed  c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\std_lib_facilities.h 213 81  HelloWorld
    21  IntelliSense: expected a ';'    c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\std_lib_facilities.h 213 107 HelloWorld

1 个答案:

答案 0 :(得分:0)

升级到visual studio 2015允许我使用客户头文件&#34; std_lib_facilities.h&#34;编译源文件。由作者提供。

感谢大家的指导和反馈。