C++ Win32-API-include <string>

Ich versuche ohne Glück zu gehören strings in meinem C++ Win32-API-Einsteiger-Projekt. Der code wird nicht kompiliert, wenn ich definieren string. Was ist Los?


Details:

Arbeitete ich in Dev C++, hab aber jetzt gewechselt zu Code::Blocks unter Verwendung des (Standard?) "Gnu GCC Compiler".

Hier sind die code-Fällen habe ich versucht, alle ähnlichen, mit dem Ergebnis:

Erfolgreich kompiliert:

#include <windows.h>
#include <string.h>  //<string> throws "no such file or directory"

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
//...the rest works perfectly, omitted in following examples

Ausfällt:

#include <windows.h>
#include <string.h>

//Error: "string" does not name a type
string myString;  

//...WndProc

Erfolgreich kompiliert:

#include <windows.h>
#include <string.h>
using namespace std;

//...WndProc

Ausfällt:

#include <windows.h>
#include <string.h>
using namespace std;

//Error: "string" does not name a type
string myString; 

//...WndProc

Ausfällt:

#include <windows.h>
#include <string.h>

//Error: expected constructor, destructor, or type conversion before "myString"
//Error: expected ',' or ';' before "myString"
std::string myString; 

//...WndProc

Diese Frage stellte ich vor ein paar Tagen aber gelöscht, weil es schien wie eine dumme Frage. Es war jedoch nicht gelöst, und jetzt hat komm zurück zu verfolgen mich. Vielen Dank im Voraus.

InformationsquelleAutor Ben | 2010-11-25

Schreibe einen Kommentar