[cfe-dev] clang, static/inline, and windows.h
Andrew
munin at mimisbrunnr.net
Wed May 18 07:40:58 PDT 2011
There is one wrinkle I forgot to add, and I'm not sure how much it
changes. Consider the following declarations:
int a1(int k);
__inline int a1(int k) { return k; }
this happens with Int64ShllMod32 in winnt.h. I hacked clang so that it
would interpret __inline and __forceinline as static and set the
function storage class appropriately, but the previous definitions
cause clang to error since then it would see it as:
int a1(int k);
static inline int a1(int k){ ... }
which is bad.
__inline is a keyword for GCC already, isn't it? it seems to be
aliased to "inline" in the td file.
What do you mean by MS mode? Where is that controlled?
Thank you,
Andrew
On Wed, May 18, 2011 at 10:16 AM, David Chisnall <theraven at sucs.org> wrote:
> On 18 May 2011, at 14:46, Andrew wrote:
>
>> It seems that MSVC silently promotes any function declared __inline or
>> __forceinline to static (or something equivalent/similar). My thinking
>> is adding in a "compatibility" layer to clang so that when dealing
>> with windows header files clang also promotes any function defined as
>> inline to static storage. What does the list think? Is this a good
>> idea? If it is, where would a good place to start in clang be to
>> implement it? If it isn't a good idea, what would be?
>
>
> It sounds like __inline is equivalent to static inline and __forceinline to __attribute__((always_inline)) in this case. Perhaps the solution is to do do the same thing that we do for __block, and just define __inline and __forceinline as predefined macros when in MS mode?
>
> David
>
> -- Sent from my Apple II
>
>
More information about the cfe-dev
mailing list