我遇到一个问题,在我尝试构建以下模块的时候,我在Linux环境下用Vim+gcc/g++编译器能够进行成功编译并执行程序。但是在Windows平台使用Visual Studio + MSVC进行编译的时候就会报错,提示有一堆xstring问题
#ifndef _VALUE_H_
#define _VALUE_H_
#include
class Value{
private:
std::string m_value;
public:
Value();
~Value();
Value(const int);
Value(const char*);
Value(const std::string&);
Value(const bool);
std::string str();
void operator= (const int);
void operator= (const char*);
void operator= (const std::string&);
void operator= (const bool);
operator int() const;
operator const char*() const;
operator std::string() const;
operator bool() const;
friend std::ostream& operator<< (std::ostream&, const Value&);
};
std::ostream& operator<< (std::ostream&,const Value&);
#endif
进行编译后的结果如下:
在Linux平台下用g++编译器能够正常编译运行,无报错
我根据以下网址,在该头文件中加入这个头文件就能够解决问题,两个平台都能够顺利编译
#include
https://cloud.tencent.com/developer/ask/sof/1003585
有人知道这是为什么吗?为什么在Linux平台就不需要使用这个头文件也能编译,但在windows(或因为MSVC造成?)下就必须添加这个头文件才可以?