CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Exporting a typedef'd symbol

    A 3rd-party DLL I'm compiling contains the following class (in abbreviated form):-

    Code:
    class __declspec(dllexport) ChordProvider
    {
      public:
        ChordProvider () {}  // <--- This gets exported okay
    
        typedef std::map<std::string,Intervals> ChordNameToIntervals;
        static ChordNameToIntervals tet12_chords; // <--- tet12_chords doesn't get exported
    };
    The typedef'd symbol doesn't get exported for some reason. Is that fixable?

    [Edit...] I tried a few searches via Google / StackOverflow etc and the consensus seems to be that typedefs are compile time objects which should be accessible from outside the DLL without needing to get exported - but I must admit, that's not what I'm seeing here

    [Update...] Adding this line to the corresponding cpp file fixed the problem

    Code:
    __declspec(dllexport)  ChordProvider::ChordNameToIntervals ChordProvider::tet12_chords;
    Last edited by John E; April 14th, 2026 at 01:19 PM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,923

    Re: Exporting a typedef'd symbol

    The issue is that tet12_chords is static. As you're found, statics need special handling for export.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Re: Exporting a typedef'd symbol

    Thanks 2kaud - I haven't used CodeGuru for a while because for a looong time it wasn't sending people emails whenever someone replied to their post but it looks like that might be working again...woohoo!
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #4
    Join Date
    May 2026
    Posts
    1

    Re: Exporting a typedef'd symbol

    Just to add for clarity: the typedef itself isn't the issue since it's only a compile-time alias. The real point is that `tet12_chords` is a static data member, so it needs an explicit exported definition in the .cpp - exactly like you did.xx
    Good catch
    Last edited by 2kaud; May 6th, 2026 at 03:25 AM. Reason: URL removed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured