[cfe-dev] Extra #defines for Windows SDK 6.0a/VS2008

per at lumai.se per at lumai.se
Fri Aug 6 03:02:52 PDT 2010


Great, I'm all for setting _INTEGRAL_MAX_BITS. It is defined by the MSVC 
compiler. All the mentioned defines are described at
http://msdn.microsoft.com/en-us/library/b0084kay%28VS.80%29.aspx
The code (<oaidl.h>) that is fixed by __STDC__ resembles

#if !__STDC__ && (_MSC_VER <= 1000)
	/* Create a struct with a member named "bool" = non-C++ */
#else
	/* Don't create the offending struct */
#endif

, so to remedy this either __STDC__ must be defined or _MSC_VER must be 
set to some value such as "1100" which might be weird since it implies 
the presence of the MSVC compiler.

As the page above states, __STDC__ = "Indicates full conformance with 
the ANSI C standard" which is the Microsoft definition of C. My guess is 
that it is _much_ less standardized than clang -strict would imply?

The problem is that this is plainly broken code in the SDK. I would not 
suggest allowing "bool" as an identifier even under ms-extensions ;-)

Fiddling with these things is boring but allowing clang to work as a 
drop-in replacement on a wider existing Windows code base would be a 
good thing, at least in my mind.

Btw, how do I invoke the Windows COFF writer? Got lost in the options...

-- 
Per Lindén

Douglas Gregor skrev 2010-08-06 10:43:
>
> On Aug 5, 2010, at 2:58 PM, per at lumai.se wrote:
>
>> Hi all,
>>
>> here's a proposed patch for clang/lib/Basic/Targets.cpp::VisualStudioWindowsX86_32TargetInfo that adds three new defines. This allows<windows.h>  pass clang compilation both in C and C++. Comments?
>
> Does the Visual Studio compiler actually define all of these macros? We shouldn't be defining any macros just to make things seem to work (e.g., we can't define WIN32_LEAN_AND_MEAN by default). Rather, we should define the same macros that Visual Studio does and, if necessary, we should implement more Microsoft-specific extensions (or even bugs) under -fms-extensions.
>
> _INTEGRAL_MAX_BITS makes sense to define, because it's documented to be defined by Visual Studio.
>
> __STDC__ should probably only be defined in C mode when -pedantic is specified or we're not in Microsoft mode. The logic in InitPreprocessor.cpp could use some tweaking.
>
> 	- Doug





More information about the cfe-dev mailing list