juce_data_structures.cpp does not compile for DLL build


#1


With Juce 2.1.3, I'm currently puzzled as to why juce_data_structures.cpp, juce_events.cpp and juce_gui_basics.cpp refuse to compile with JUCE_DLL_BUILD=1 (VC 2010 project also inherits _WINDLL and _MBCS), while everything is fine for much similar EXE builds. 

This last worked without problems with Juce 2.0.32, so the projects should be configured properly.

The errors are related to ContainerDeletePolicy, with the following error variants being reported:

C2248: "juce::ValueTree::SharedObject": can not access private class declared in juce::ValueTree
C2248: "juce::PopupMenu::HelperClasses": can not access private struct declared in  juce::PopupMenu
C2248: "juce::MultiTimer::MultiTimerCallback": can not access private struct declared in juce::MultiTimer

(not sure if my translation of the MSVC message to English is correct)

What really bugs me is how this could depend on DLL or not.

Needless to say this blocks everything currently.

Any idea how to fix this?
Thanks in advance!
 


#2

After diving into the adventure of understanding compiler quirks, I finally found a solution.

Jules, you are a genious. You already implemented the JUCE_PUBLIC_IN_DLL_BUILD macro which comes in handy here.
​These are the fixes:

In file juce_ValueTree.h:

private:
    //==============================================================================
    JUCE_PUBLIC_IN_DLL_BUILD (class SharedObject)
    friend class SharedObject;

    ReferenceCountedObjectPtr<SharedObject> object;
    ListenerList<Listener> listeners;
    ...

In file juce_PopupMenu.h:

private:
    //==============================================================================
    JUCE_PUBLIC_IN_DLL_BUILD (class Item)
    JUCE_PUBLIC_IN_DLL_BUILD (struct HelperClasses)
    JUCE_PUBLIC_IN_DLL_BUILD (friend struct HelperClasses)
    JUCE_PUBLIC_IN_DLL_BUILD (friend class MenuBarComponent)

    OwnedArray<Item> items;
    LookAndFeel* lookAndFeel;
    ...

 

In file juce_juce_MultiTimer.h:

private:
    JUCE_PUBLIC_IN_DLL_BUILD (struct MultiTimerCallback)
    SpinLock timerListLock;
    ...

Still puzzled why this would be necessary in the first place, but happy it works again.


#3

Ok, thanks for the heads-up, I'll add that. (But surely no need to wrap the 'friend' declarations in the macro too??)

 


#4

But surely no need to wrap the 'friend' declarations in the macro too?

Oh, that was just to make sure all potential cases are covered and move on. I have no doubt you will know better.