jeudi 26 mars 2015

Error: string is not a member of std all of a sudden

In Visual Studio 2013 C++/CLI, I have created a variable in my namespace in a header file of std::string type. When I entered std::, I chose string from the list. At first it was beautiful. Then after some time I came back to this spot and found string underlined with red with IDE saying "'string' : is not a member of 'std'". I entered std:: and there was no string in it. I hit Ctrl+S, and everything got in order - no errors. Then I edited some functions in the cpp file, hit Build solution and I got "error C2039: 'string' : is not a member of 'std'" again. This time Save doesn't help. std::string is not underlined by red, but I get that error when building the solution. I haven't messed with any includes and namespaces. I only edited my own functions.


I added #include to the header and then I get this error:



1>ConsoleApplication2.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > ADOC::time_format_str" (?time_format_str@ADOC@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in BuildADOC.obj
1>C:\Users\Andrius\Documents\Visual Studio 2013\Projects\ConsoleApplication3WithClass\Debug\ConsoleApplication2.exe : fatal error LNK1169: one or more multiply defined symbols found


Here's an excerpt from my header file:



#pragma once

#using <System.dll>
#using <System.Xml.dll>
#using <System.Security.dll>
#using <mscorlib.dll>
#using <System.Numerics.dll>
#using <System.Windows.Forms.dll>

#include <typeinfo>
//#include <string>

namespace MyNamespace {

using namespace System::IO;

using namespace System;
using namespace System::Xml;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::Xml;
using namespace System::Security::Cryptography::X509Certificates;
using namespace System::Collections::Generic; //List<T>

std::string time_format = "yyyy-MM-ddTHH:mm:ssK";


What could I do to make it see string in std again? What could be resons it seeing the string at first even without #include (and got built multiple times with no problems) and not now?


Aucun commentaire:

Enregistrer un commentaire