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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C2491: 'XXX'::entries' : definition of dllimport function not allowed

error C2491: 'XXX'::entries' : definition of dllimport function not allowed

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 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.
  • A Offline
    A Offline
    Andraw111
    wrote on last edited by
    #1

    Hi, dear all, I have a DLL file created in C++ 6.0, now move to VS2008 and get compile error. in header file: #define XXXPORT __declspec(dllimport) template <class TP> class XXXPORT TPtrList { public: int entries(bool deleted = false) const; TP *operator[](int n); const TP *operator[](int n) const; .............. .............. } in .cpp file template <class TP> inline int TPtrList<TP>::entries(bool deleted) const { ......... } template <class TP> inline TP *ABSTPtrList::operator[](int n) { .........} In C++, they are fine, but in VS2008, When I compile it, I got error C2491: 'TPtrList<TP>'::entries' : definition of dllimport function not allowed error C2491: 'TPtrList<TP>::operator []' : definition of dllimport function not allowed What cause this problem? Thanks!

    A 1 Reply Last reply
    0
    • A Andraw111

      Hi, dear all, I have a DLL file created in C++ 6.0, now move to VS2008 and get compile error. in header file: #define XXXPORT __declspec(dllimport) template <class TP> class XXXPORT TPtrList { public: int entries(bool deleted = false) const; TP *operator[](int n); const TP *operator[](int n) const; .............. .............. } in .cpp file template <class TP> inline int TPtrList<TP>::entries(bool deleted) const { ......... } template <class TP> inline TP *ABSTPtrList::operator[](int n) { .........} In C++, they are fine, but in VS2008, When I compile it, I got error C2491: 'TPtrList<TP>'::entries' : definition of dllimport function not allowed error C2491: 'TPtrList<TP>::operator []' : definition of dllimport function not allowed What cause this problem? Thanks!

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      This looks like you're defining the functions when doing the dll import... when all you should have is function prototypes. You probably want to define XXPORT up there to say dllexport.

      A 1 Reply Last reply
      0
      • A Albert Holguin

        This looks like you're defining the functions when doing the dll import... when all you should have is function prototypes. You probably want to define XXPORT up there to say dllexport.

        A Offline
        A Offline
        Andraw111
        wrote on last edited by
        #3

        Yes, you are right. I just change to dllexport, then I can add function implementation to it, so can be used by other class inside this DLL. Thanks!

        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