<div dir="ltr"><div dir="ltr">On Mon, Sep 27, 2021 at 8:28 AM John Emmas via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Aaaargh!!  I just realised this was a spelling mistake at my end.  <br>
Here's my original example...<br>
<br>
On 22/09/2021 13:22, John Emmas wrote:<br>
><br>
> #if defined (BUILDING_DLL)<br>
>   #define DLL_API __declspec(dllexport)<br>
> #else<br>
>   #define DLL_API __declspec(dllimport)<br>
> #endif<br>
><br>
<br>
But because the library can be built for different platforms, the actual <br>
code here was slightly more complicated - looking like this:-<br>
<br>
     #if defined (COMPILER_MSVC)<br>
       #if defined (BUILDING_DLL)<br>
         #define DLL_API __declspec(dllexport)<br>
       #else<br>
         #define DLL_API __declspec(dllimport)<br>
       #endif<br>
     #else<br>
         #define DLL_API<br>
     #endif<br>
<br>
I'd changed the first line to read #if defined (COMPILER_MSVC) || <br>
defined (COMPILER_CLANG) - except that in the actual VS project file I'd <br>
then mis-spelled COMPILER_CLANG - so apologies and thanks to everyone <br>
who's helped here...  I'd spent days looking through header files and <br>
source files without even thinking to check the VS project itself :-(<br>
<br>
Fixing this has made it compile and link with optimizations disabled <br>
('/Ob0') but I guess I'll need to check what happens once I enable them <br>
again.  If header-defined functions are routinely treated as inlined, I <br>
guess the problem might come back again :-(<br>
<br>
I suppose this brings up an obvious question...  when building with MSVC <br>
I could have used the built-in preprocessor directive _MSC_VER rather <br>
than using my own COMPILER_MSVC - so does Clang have something built-in <br>
that's always similarly #defined?  Or even better - does anyone know if <br>
there's some preprocessor directive that's always specified for both <br>
compilers (i.e. when they're being used with Visual Studio) ?<br></blockquote><div><br><a href="https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions">https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions</a><br>"<span style="color:rgb(51,51,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14.4px;text-align:justify">For compatibility with existing code that compiles with MSVC, clang defines the </span><code class="gmail-docutils gmail-literal gmail-notranslate" style="background-color:rgb(226,226,226);font-size:1em;color:rgb(51,51,51);text-align:justify"><span class="gmail-pre" style="hyphens: none;">_MSC_VER</span></code><span style="color:rgb(51,51,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14.4px;text-align:justify"> and </span><code class="gmail-docutils gmail-literal gmail-notranslate" style="background-color:rgb(226,226,226);font-size:1em;color:rgb(51,51,51);text-align:justify"><span class="gmail-pre" style="hyphens: none;">_MSC_FULL_VER</span></code><span style="color:rgb(51,51,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14.4px;text-align:justify"> macros."</span> </div></div></div>