Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-23 Thread Jeffrey Walton via cfe-users
On Thu, Sep 23, 2021 at 12:48 PM David Blaikie via cfe-users wrote: > > On Thu, Sep 23, 2021 at 3:34 AM John Emmas via cfe-users > wrote: >> ... >> Over on llvm-dev I'm trying to persuade them that declaring something as >> __declspec(dllimport) should automatically exclude it from being >> inli

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-23 Thread John Emmas via cfe-users
Many thanks Dave, Over on llvm-dev a contributer called Hans found this on Microsoft's MSDN site:- https://docs.microsoft.com/en-us/cpp/cpp/defining-inline-cpp-functions-with-dllexport-and-dllimport So the current theory is that Microsoft's compiler can indeed inline DLL functions - but p

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-23 Thread David Blaikie via cfe-users
On Thu, Sep 23, 2021 at 3:34 AM John Emmas via cfe-users < cfe-users@lists.llvm.org> wrote: > On 22/09/2021 18:21, Reid Kleckner via cfe-users wrote: > > Looking back in the thread, I found the example code, and I see that > > MSVC refuses to inline this helper, but clang will inline it. I > > bel

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-23 Thread John Emmas via cfe-users
On 22/09/2021 18:21, Reid Kleckner via cfe-users wrote: Looking back in the thread, I found the example code, and I see that MSVC refuses to inline this helper, but clang will inline it. I believe clang is permitted to inline it, MSVC will export the static data member (_the_keyboard), so every

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-22 Thread Reid Kleckner via cfe-users
Looking back in the thread, I found the example code, and I see that MSVC refuses to inline this helper, but clang will inline it. I believe clang is permitted to inline it, MSVC will export the static data member (_the_keyboard), so everything should work as long as you provide a definition of _th

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-22 Thread David Blaikie via cfe-users
Probably Reid and Hans are folks to start with for Windows support On Wed, Sep 22, 2021 at 4:38 AM Jeffrey Walton via cfe-users < cfe-users@lists.llvm.org> wrote: > On Wed, Sep 22, 2021 at 7:21 AM John Emmas via cfe-users > wrote: > > > > On 21/09/2021 14:24, John Emmas via cfe-users wrote: > >

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-22 Thread Jeffrey Walton via cfe-users
On Wed, Sep 22, 2021 at 7:21 AM John Emmas via cfe-users wrote: > > On 21/09/2021 14:24, John Emmas via cfe-users wrote: > > > > clang-cl /? reveals that it'll handle the Microsoft variant of /Ob0 > > ... > All the signs here are that Clang is still trying to inline stuff - even > when it's been t

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-22 Thread John Emmas via cfe-users
On 21/09/2021 14:24, John Emmas via cfe-users wrote: clang-cl /? reveals that it'll handle the Microsoft variant of /Ob0 [...] So do you happen to know if clang-cl produces some kinda log file (i.e. that'd let me see which commands it actually received?) All the signs here are that Clang

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-21 Thread John Emmas via cfe-users
I just found something else which might be significant... I noticed that when linking this exe, I had a linker option enabled called /FORCE:MULTIPLE If I remove that option, the Clang linker then gives me a list of about a dozen duplicated symbols. And with that option I get a similarly siz

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-21 Thread John Emmas via cfe-users
On 21/09/2021 13:49, Jeffrey Walton wrote: The U&L option is -fno-inline. But I think Clang has an option to consume MSVC style options, so you may be able to use /Ob. I think you can check which MSVC style options Clang accepts with 'clang-cl /?' or 'clang-cl -?'. Thanks again Jeff and you'

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-21 Thread Jeffrey Walton via cfe-users
> ... > I checked this morning and sure enough the "/Ob" option doesn't get sent > if I build with VS2019 and Clang - so I'm guessing "/Ob0" wouldn't be > recognised by Clang's compiler? > > So does Clang have it's own command-line option to disable inline > function expansion? Or is that somethi

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-21 Thread John Emmas via cfe-users
Many thanks Jeff & David, Overnight I remembered that Visual Studio itself offers a specific option to disable inline function expansion. For MSVC itself, this gets done by setting a compiler option called "/Ob" ("/Ob0" indicates disabled). If "/Ob0" isn't specified at compile time, inlining

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-20 Thread Jeffrey Walton via cfe-users
On Mon, Sep 20, 2021 at 7:37 AM John Emmas via cfe-users wrote: > > Hi there - I'm building quite a complex Windows program here using > VS2019. Obviously there's an EXE and there's maybe 30 or so DLLs. Some > DLL's might have code which looks like this in a header file:- > > class whatever

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-20 Thread David Blaikie via cfe-users
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. On Mon, Sep 20, 2021 at 6:56 AM John Emmas via cfe-users < cfe-use

Re: [cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-20 Thread John Emmas via cfe-users
On 20/09/2021 12:36, John Emmas via cfe-users wrote: But if I switch VS2019 to use Clang (when building the EXE) Clang's linker will complain that it can't find the variable 'revision_num'. But of course, 'revision_num' is an internal variable that's private to the DLL [...] - so is there ma

[cfe-users] Clang (with Visual Studio) wrongly complains about missing variables

2021-09-20 Thread John Emmas via cfe-users
Hi there - I'm building quite a complex Windows program here using VS2019. Obviously there's an EXE and there's maybe 30 or so DLLs. Some DLL's might have code which looks like this in a header file:- class whatever { static int revision_num; }; or if there's no class involved