<div dir="ltr">I'm not sure it's the right/necessary solution, but one way would be to move the function definition (for the_keyboard) out of line (define it in some .cpp/.cc/whatever file, not in the header) - if you don't want it to be inlined.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 20, 2021 at 6:56 AM John Emmas via cfe-users <<a href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 20/09/2021 12:36, John Emmas via cfe-users wrote:<br>
><br>
> But if I switch VS2019 to use Clang (when building the EXE) Clang's <br>
> linker will complain that it can't find the variable 'revision_num'.  <br>
> But of course, 'revision_num' is an internal variable that's private <br>
> to the DLL [...] - so is there maybe some linker option that'll tell <br>
> Clang to ignore variables if the code never needs access to them?<br>
><br>
<br>
Another possibility just occurred to me...  here's a real-world example <br>
from our code:-<br>
<br>
#if defined (BUILDING_DLL)<br>
   #define DLL_API __declspec(dllexport)<br>
#else<br>
   #define DLL_API __declspec(dllimport)<br>
#endif<br>
<br>
namespace Gtkmm2ext {<br>
<br>
   class DLL_API Keyboard<br>
   {<br>
     public:<br>
       Keyboard ();<br>
       ~Keyboard ();<br>
<br>
       static Keyboard& the_keyboard() { return *_the_keyboard };<br>
<br>
     protected:<br>
       static Keyboard* _the_keyboard;<br>
   };<br>
<br>
} /* namespace */<br>
<br>
The above example is from a DLL but when I try to build the <br>
corresponding EXE, Clang's linker complains that it can't find <br>
'_the_keyboard' - so did the compiler (maybe) implement its call to <br>
'the_keyboard()' as inline code, rather than importing it from the DLL?  <br>
Maybe for very simple code like this, Clang will try to be clever and <br>
implement stuff inline if it can?  And if so, is there some way to turn <br>
off that feature?  Thanks,<br>
<br>
John<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>