vector problem



  • main.h
    
    #ifndef __CPLUSPLUS
    #define EXPORT extern "C" __declspec (dllexport)
    #else
    #define EXPORT __declspec (dllexport)
    #endif
    
    EXPORT void CALLBACK NewInt(int);
    EXPORT int CALLBACK SizeInt();
    
    main.cpp
    
    #include <windows.h>
    #include <iostream>
    #include <vector>
    #include "main.h"
    
    vector<int> VecInt;
    
    EXPORT void CALLBACK NewInt(int value)
    {
    	//VecInt.push_back(value);
    }
    
    EXPORT int CALLBACK SizeInt()
    {
    	//return VecInt.size();
    }
    

    Fehlermeldung:
    g:\Entwicklung\VisualC++\SmartPtr\main.cpp(6): error C2143: syntax error : missing ';' before '<'
    g:\Entwicklung\VisualC++\SmartPtr\main.cpp(6): error C2501: 'vector' : missing storage-class or type specifiers

    Also ich weiß hier nicht mehr weiter. Hatte vorher noch mit vector in einer Konsolenanwendung gearbeitet ohne probleme, und hier (ist eine DLL) will er das absolut nicht. Kann mir da jemand helfen mal bitte.



  • vector liegt im Namespace std. So sucht der Compiler nur im globalen Namespace, wo er natürlich nichts findet.

    http://tutorial.schornboeck.net/namespace.htm



  • supi, danke, habs grad selbst gefunden. nun tut sich aber ein neues problem auf:

    #include <windows.h>
    #include <vector>
    #include "main.h"
    using namespace std;
    
    struct T_INT{char *Bez; int value;};
    
    vector<T_INT> VecInt;
    
    EXPORT void CALLBACK NewInt(int value)
    {
    	VecInt.push_back(was muß ich hier eintragen um auf den char* bzw den int zu belegen);
    }
    

    danke im vorraus


Anmelden zum Antworten