Ich bin mit einer interessanten Situation konfrontiert und möchte mit allen teilen. Definitiv, wenn jemand helfen kann, werde ich dankbar sein!std :: map :: find (char *) funktioniert nicht auf 64bit Maschine im Debug-Modus
#include "stdafx.h"
#include <map>
#define DEF_NAME1 "NAME1"
#define DEF_NAME2 "NAME2"
#define DEF_NAME3 "NAME3"
#define DEF_NAME4 "NAME4"
struct TInfo
{
const char * TName;
const char * TArray1[100];
const char * TArray2[100];
};
typedef std::map<const char*, TInfo*> TInfoMap;
typedef std::pair<const char*,TInfo*> TInfoPair;
static TInfoMap tinfomap;
TInfo TInfoArray[] =
{
{DEF_NAME1,{""}, {""}},
{DEF_NAME2,{""}, {""}},
{DEF_NAME3,{""}, {""}},
{DEF_NAME4,{""}, {""}}
};
TInfoMap* GetTInfoMap()
{
for (int i = 0; i < 3 ; i++)
tinfomap.insert(TInfoPair(TInfoArray[i].TName,&TInfoArray[i]));
return &tinfomap;
}
int _tmain(int argc, _TCHAR* argv[])
{
char *name="NAME3";
TInfo* ptr = new TInfo();
TInfoMap* map1 = GetTInfoMap();
if (map1->find(name) == map1->end())
printf("Not found");
else
printf("Found!");
return 0;
}
Ich bin auf Windows 2003 Server 64bit. Ich bekomme die Ausgabe "Found!" wenn ich dieses Programm im Freigabemodus kompiliere/laufe und die Ausgabe "Nicht gefunden" ist, wenn ich dieses Programm im Debug-Modus kompiliere/laufe.
Irgendeine Idee?
Grüße,
Azher
Vielen Dank für die Antwort. Dann sollte es auch im Release-Modus nicht funktionieren. Es ist verwirrend, weil es im Freigabemodus funktioniert, aber nicht im Debug-Modus. –
Denken kann in Debug- und Release-Modi anders funktionieren. Dies ist ein bekanntes Problem (zum Beispiel http://www.flounder.com/debug_release.htm) – dimba
idimba, Großartig !!! Danke für die Hilfe –