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. Unresolved extern "dwTlsIndex" exported function in dll

Unresolved extern "dwTlsIndex" exported function in dll

Scheduled Pinned Locked Moved C / C++ / MFC
help
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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I have a c DLL. the Dllmain and the exported function(s) are in different source files. Since the exported function need the value of the variable dwTlsindex. I decalre as an extern I both define it and declare it in DllMain

    extern DWORD dwTlsIndex;
    static DWORD dwTlsIndex;
    BOOL APIENTRY DllMain( HMODULE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    )

    in the exported function the following is the definition I know I have used the extern storage specifier with out any problem many times maybe there is something different because this is a DLL as the linker cant resolve dwTlsIndex

    #else

     \_\_declspec(dllexport) void opendata(char \*);
    

    #endif

     extern DWORD dwTlsIndex;
    
     void opendata(char \*filename)
     {
    	 typedef void \*(DLL\_FN)(char \*);
    
    CPalliniC 1 Reply Last reply
    0
    • F ForNow

      Hi I have a c DLL. the Dllmain and the exported function(s) are in different source files. Since the exported function need the value of the variable dwTlsindex. I decalre as an extern I both define it and declare it in DllMain

      extern DWORD dwTlsIndex;
      static DWORD dwTlsIndex;
      BOOL APIENTRY DllMain( HMODULE hModule,
      DWORD ul_reason_for_call,
      LPVOID lpReserved
      )

      in the exported function the following is the definition I know I have used the extern storage specifier with out any problem many times maybe there is something different because this is a DLL as the linker cant resolve dwTlsIndex

      #else

       \_\_declspec(dllexport) void opendata(char \*);
      

      #endif

       extern DWORD dwTlsIndex;
      
       void opendata(char \*filename)
       {
      	 typedef void \*(DLL\_FN)(char \*);
      
      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Quote:

      extern DWORD dwTlsIndex; static DWORD dwTlsIndex;

      You should just write

      DWORD dwTlsIndex;

      because:

      • You don't need the extern declaration in the file that defines the variable.
      • The static keyword makes the variable having file-scope (link failure).

      In testa che avete, signor di Ceprano?

      F 1 Reply Last reply
      0
      • CPalliniC CPallini

        Quote:

        extern DWORD dwTlsIndex; static DWORD dwTlsIndex;

        You should just write

        DWORD dwTlsIndex;

        because:

        • You don't need the extern declaration in the file that defines the variable.
        • The static keyword makes the variable having file-scope (link failure).
        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Tried it still getting unresolved maybe something I have to do in my project

        F 1 Reply Last reply
        0
        • F ForNow

          Tried it still getting unresolved maybe something I have to do in my project

          F Offline
          F Offline
          ForNow
          wrote on last edited by
          #4

          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