Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using STL in a DLL

Using STL in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicsquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gian
    wrote on last edited by
    #1

    I've created a DLL from a class of mine where i use two std::vector<> members to store something. My problem is that when i insert an element on the vector, the first operation on the vector (clear it, read the first element,etc) cause an error on the heap: File: dbgheap.c Line: 1044 Expression: _CrtIsValidHeapPointer(pUserData) HEAP[Print.exe]: Invalid Address specified to RtlValidateHeap( 28d0000, 28e3bd0 ) Using the class inside the program works well. It's a problem of the STL, something to include in the DLL compiling options?

    P 1 Reply Last reply
    0
    • G Gian

      I've created a DLL from a class of mine where i use two std::vector<> members to store something. My problem is that when i insert an element on the vector, the first operation on the vector (clear it, read the first element,etc) cause an error on the heap: File: dbgheap.c Line: 1044 Expression: _CrtIsValidHeapPointer(pUserData) HEAP[Print.exe]: Invalid Address specified to RtlValidateHeap( 28d0000, 28e3bd0 ) Using the class inside the program works well. It's a problem of the STL, something to include in the DLL compiling options?

      P Offline
      P Offline
      pete mcquain
      wrote on last edited by
      #2

      Gian wrote: It's a problem of the STL, something to include in the DLL compiling options? It sounds more like it's a DLL-boundary issue with whatever chunk of memory you are trying to push onto the vector. Perhaps some sample code would help. -pete

      G 1 Reply Last reply
      0
      • P pete mcquain

        Gian wrote: It's a problem of the STL, something to include in the DLL compiling options? It sounds more like it's a DLL-boundary issue with whatever chunk of memory you are trying to push onto the vector. Perhaps some sample code would help. -pete

        G Offline
        G Offline
        Gian
        wrote on last edited by
        #3

        my dll header is #ifndef LFONTRENDERER_H #define LFONTRENDERER_H //-------------------------------------------------- # define GFONT_API __declspec(dllexport) #include #include #ifdef _WIN32 #include #endif // _WIN32 #include //-------------------------------------------------- typedef unsigned int uint; typedef unsigned char byte; #define DEFAULT_HEIGHT 99999 struct LCharCoords { GLfloat left; GLfloat top; GLfloat right; GLfloat bottom; bool enabled; float widthFactor; }; struct LFont { std::string name; GLuint textureId; uint defaultHeight; uint height; float widthScale; bool italic; GLfloat angle; GLfloat r, g, b; LCharCoords chars[256]; }; struct LStringData { std::string str; uint font; // the font to be used uint height; // the height of the font GLfloat r, g, b; // the color GLfloat angle; // the rotation angle GLfloat x, y; // the position float widthScale; // width scale bool italic; // true if the font is italic }; //-------------------------------------------------- class GFONT_API LFontRenderer { public: // default constructor, initializes the object LFontRenderer(); // the destructor, automatically called by delete virtual ~LFontRenderer(); // returns the number of fonts loaded uint GetFontCount(); // returns the name of the given font, index _must_ be smaller than GetFontCount() const std::string& GetFontName(uint index); // sets the active font, this function is also available in a version that takes the index as parameter void SetActiveFont(const std::string& name); // sets the active font, this function is also available in a version that takes the name // of the font as parameter void SetActiveFont(uint index); // returns the index of the active font, throws an exception if no fonts are loaded uint GetActiveFont(); // this function loads a font from a file and adds it to the list of fonts it returns the index of // the new font. The font name paramater is a name for the font that can be used with // SetActiveFont() etc. uint LoadFont(const std::string& fontname, const std::string& filename); // removes all fonts and clears any memory allocated void Clear(); // sets the height of the current font void SetHeight(uint height); // sets the color of the active

        G 1 Reply Last reply
        0
        • G Gian

          my dll header is #ifndef LFONTRENDERER_H #define LFONTRENDERER_H //-------------------------------------------------- # define GFONT_API __declspec(dllexport) #include #include #ifdef _WIN32 #include #endif // _WIN32 #include //-------------------------------------------------- typedef unsigned int uint; typedef unsigned char byte; #define DEFAULT_HEIGHT 99999 struct LCharCoords { GLfloat left; GLfloat top; GLfloat right; GLfloat bottom; bool enabled; float widthFactor; }; struct LFont { std::string name; GLuint textureId; uint defaultHeight; uint height; float widthScale; bool italic; GLfloat angle; GLfloat r, g, b; LCharCoords chars[256]; }; struct LStringData { std::string str; uint font; // the font to be used uint height; // the height of the font GLfloat r, g, b; // the color GLfloat angle; // the rotation angle GLfloat x, y; // the position float widthScale; // width scale bool italic; // true if the font is italic }; //-------------------------------------------------- class GFONT_API LFontRenderer { public: // default constructor, initializes the object LFontRenderer(); // the destructor, automatically called by delete virtual ~LFontRenderer(); // returns the number of fonts loaded uint GetFontCount(); // returns the name of the given font, index _must_ be smaller than GetFontCount() const std::string& GetFontName(uint index); // sets the active font, this function is also available in a version that takes the index as parameter void SetActiveFont(const std::string& name); // sets the active font, this function is also available in a version that takes the name // of the font as parameter void SetActiveFont(uint index); // returns the index of the active font, throws an exception if no fonts are loaded uint GetActiveFont(); // this function loads a font from a file and adds it to the list of fonts it returns the index of // the new font. The font name paramater is a name for the font that can be used with // SetActiveFont() etc. uint LoadFont(const std::string& fontname, const std::string& filename); // removes all fonts and clears any memory allocated void Clear(); // sets the height of the current font void SetHeight(uint height); // sets the color of the active

          G Offline
          G Offline
          Gian
          wrote on last edited by
          #4

          in // the array of fonts std::vector m_fonts; // the strings to be rendered std::vector m_strings; the first is the template of LFont and the second of LStringData (the < and > are missing in the post)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups