C++程序是在VC++2010中编译的,而不是在Visual C++6.0中编译的
C++ program gets compiled in VC++ 2010 but not in Visual C++ 6.0
我不会粘贴整个程序,只粘贴包含的文件和错误,我非常确信,错误就在那里!
VS 2010 中包含的文件
#include <cstdlib>
#include <windows.h>
#include "iostream"
#include "conio.h"
#include "vector"
#include "math.h"
#include <string.h>
#include <bitset>
Visual C++6.0 中包含的文件
#include <cstdlib>
#include <windows.h>
#include "iostream"
#include "conio.h"
#include "vector"
#include "math.h"
#include <string.h>
#include <bitset>
#include <String>
好吧,只有一个区别,我在Visual C++2006中添加了#include <String>
,这个特定的文件减少了读取为的错误
错误C2678:二进制"!=":没有定义接受类型为()"class std::basic_string,class std:::allocater>"的左侧操作数的运算符(或者没有可接受的转换)
我在VS2006中仍然面临的其他主要错误是
线路:str.append(to_string((long double)(value)));
错误:error C2065: 'to_string' : undeclared identifier
线路:vector <vector <float>> distOfSectionPoint, momentAtSectionPoint, preFinalMoment, finalMoments, momentAtSectionPtOnPtLoadProfile ;
错误:error C2208: 'class std::vector' : no members defined using this type
有人能解释一下Visual C++2006中出了什么问题吗??
假设to_string
是std::to_string
,那么这是一个C++11函数,在旧的编译器中不可用。你可以拼凑出大致相同的东西,比如
template <typename T>
std::string nonstd::to_string(T const & t) {
std::ostringstream s;
s << t;
// For bonus points, add some error checking here
return s.str();
}
涉及vector
的错误是由两个闭合尖括号引起的,较旧的编译器会将其解释为单个>>
标记。在它们之间添加一个空格:
vector<vector<float> >
^
目前还不太清楚您使用的是哪种编译器,因为当时还没有Visual C++2006。如果你说的是Visual C++6.0(1998年),那么你可能就完蛋了。从那时起,已经进行了两次主要的语言修订,这使得编写该编译器和现代编译器都支持的代码变得非常困难。如果你指的是2005年或2008年,那么就要小心避免使用C++11特性。
错误C2065:"to_string":未声明的标识符
std::to_string()
是VS2010支持的C++11功能。任何早期版本的Microsoft编译器都不支持它。boost::lexical_cast
是一种替代方案。
错误C2208:"class std::vector":没有使用此类型定义成员
C++11和VS2010允许使用CCD_ 12,而C++11之前的版本则不允许。需要更改为:
vector <vector <float> > distOfSectionPoint,
//^ space here
- 编译并运行后,输出未出现在 Visual Studio 代码中
- 第三方 API 中的编译错误 - Visual Studio
- std::unique_ptr 在 GCC 中工作,但不能在 Visual Studio 中编译
- 如何在 CMake 中添加预编译标头用于 Visual Studio 生成器
- 如何使用msbuild和设置C++17命令行编译Visual Studio项目?
- 如何使用 GLFW 预编译的二进制文件编译 Visual Studio 2019 发布版本
- 我想使用 CMake 生成和编译 Visual Studio projet,我需要从构建中排除单元测试文件。有没有办法做到这一点?
- 如何在 Linux 上高效地编译 Visual Studio c++ 项目
- 如何通过Windows上的命令行编译Visual Studio的C 项目
- 在不安装 Visual Studio 的情况下编译 Visual Studio 项目
- 在LNK2038中编译Visual Studio 2010到2012 RC的MFC应用程序
- 在使用 Xbuild 编译 Visual C++ 项目时定义目标
- 在Qt Creator中编译Visual Studio 2010项目
- 如何从 C# 以编程方式编译 Visual C++ 项目
- 编译Visual c++ DLL时出现奇怪错误
- 从命令行编译Visual c++
- 如何从命令提示窗口构建和编译visual studio c++代码
- 在amd64模式下编译(visual studio 2010)
- 使用CMake编译Visual Studio 2012的SFML
- IncrediBuild在一个线程中编译Visual Studio 2010/2012解决方案的一些项目