Windows DLL __declspec(dllimport) placement


#1

I just downloaded Juce 1.52 and attempted to build a DLL using the Visual Studio 2008 build and got the a bunch of errors like this:

Looking into the code (and after expanding the JUCE_PUBLIC_API define) it was lines like this that were causing the problem

The problem only arose on global functions that returned a reference rather than a value. The VC compiler didn’t like the placement of __declspec(dllexport)
I changed it to

And things seemed to compile just fine. If I bring back in the Juce defines, the code went from:

to:

This fixed the problem. FYI, all these changes only had to take place in the juce_String.h and juce_String.cpp files.

I’m guessing this is a Windows only issue since the __declspec() doesn’t show up on other platforms. I haven’t tested anything with GCC. Not sure if attribute ((visibility(“default”))) will cause the same problem.

Perhaps a fix in the next release?
Cheers,


#2

Thanks. That’s kind of strange, I’m sure it used to work ok… Anyway, I’ll take a look and see what I can do, cheers!