__declspec(dllimport) causes compiler crash on MSVC 2010

Posted by Zero on Stack Overflow See other posts from Stack Overflow or by Zero
Published on 2012-09-13T09:12:32Z Indexed on 2012/09/13 9:38 UTC
Read the original article Hit count: 162

Filed under:
|
|

In a *.cpp file, trying to use a third party lib:

#define DLL_IMPORT 
#include <thirdParty.h>
// Third party header has code like:
// #ifdef DLL_IMPORT
//    #define DLL_DECL __declspec(dllimport)

// fatal error C1001: An internal error has occurred in the compiler.

Alternative:

#define NO_DLL
#include <thirdParty.h>
// Third party header has code like:
// #elif defined(NO_DLL)
//    #define DLL_DECL


// Compiles fine, but linker errors as can't find DLL functions
// I can reproduce results by remove macros and #define all together and manually editing the third party files to have __declspec(dllimport) or not

Has anyone come across anything similar, or can hint at the cause? (which is created using CMake). Above is actual example of 2 line *.cpp that crashes so it's narrowed down to something in the #include.

The following also work fine:

  1. Compile the examples provided by the third party (they provide a *.sln) that use dllimport/export so it doesn't appear to be the fault of the library
  2. Compile the third party lib as part of the production project (so dllexport works fine)

I've trawled the project settings pages of the two projects to try and spot differences, but have come up blank. Of course, it's possible I'm missing something as those settings pages are not the easiest to navigate. I'll get access to VS2008 in a day or so, so can compare with that. The third party library is MySql++.

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-c++