John Emmas via llvm-dev
2021-Sep-27 15:28 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
Aaaargh!! I just realised this was a spelling mistake at my end. Here's my original example... On 22/09/2021 13:22, John Emmas wrote:> > #if defined (BUILDING_DLL) > #define DLL_API __declspec(dllexport) > #else > #define DLL_API __declspec(dllimport) > #endif >But because the library can be built for different platforms, the actual code here was slightly more complicated - looking like this:- #if defined (COMPILER_MSVC) #if defined (BUILDING_DLL) #define DLL_API __declspec(dllexport) #else #define DLL_API __declspec(dllimport) #endif #else #define DLL_API #endif I'd changed the first line to read #if defined (COMPILER_MSVC) || defined (COMPILER_CLANG) - except that in the actual VS project file I'd then mis-spelled COMPILER_CLANG - so apologies and thanks to everyone who's helped here... I'd spent days looking through header files and source files without even thinking to check the VS project itself :-( Fixing this has made it compile and link with optimizations disabled ('/Ob0') but I guess I'll need to check what happens once I enable them again. If header-defined functions are routinely treated as inlined, I guess the problem might come back again :-( I suppose this brings up an obvious question... when building with MSVC I could have used the built-in preprocessor directive _MSC_VER rather than using my own COMPILER_MSVC - so does Clang have something built-in that's always similarly #defined? Or even better - does anyone know if there's some preprocessor directive that's always specified for both compilers (i.e. when they're being used with Visual Studio) ? Thanks again, John
David Blaikie via llvm-dev
2021-Sep-27 18:43 UTC
[llvm-dev] Disabling inline compilation (Clang with VS2019)
On Mon, Sep 27, 2021 at 8:28 AM John Emmas via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Aaaargh!! I just realised this was a spelling mistake at my end. > Here's my original example... > > On 22/09/2021 13:22, John Emmas wrote: > > > > #if defined (BUILDING_DLL) > > #define DLL_API __declspec(dllexport) > > #else > > #define DLL_API __declspec(dllimport) > > #endif > > > > But because the library can be built for different platforms, the actual > code here was slightly more complicated - looking like this:- > > #if defined (COMPILER_MSVC) > #if defined (BUILDING_DLL) > #define DLL_API __declspec(dllexport) > #else > #define DLL_API __declspec(dllimport) > #endif > #else > #define DLL_API > #endif > > I'd changed the first line to read #if defined (COMPILER_MSVC) || > defined (COMPILER_CLANG) - except that in the actual VS project file I'd > then mis-spelled COMPILER_CLANG - so apologies and thanks to everyone > who's helped here... I'd spent days looking through header files and > source files without even thinking to check the VS project itself :-( > > Fixing this has made it compile and link with optimizations disabled > ('/Ob0') but I guess I'll need to check what happens once I enable them > again. If header-defined functions are routinely treated as inlined, I > guess the problem might come back again :-( > > I suppose this brings up an obvious question... when building with MSVC > I could have used the built-in preprocessor directive _MSC_VER rather > than using my own COMPILER_MSVC - so does Clang have something built-in > that's always similarly #defined? Or even better - does anyone know if > there's some preprocessor directive that's always specified for both > compilers (i.e. when they're being used with Visual Studio) ? >https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions "For compatibility with existing code that compiles with MSVC, clang defines the _MSC_VER and _MSC_FULL_VER macros." -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210927/ed1e88a3/attachment.html>