[cfe-dev] Emulation of VC++ preprocessor

Edward Diener via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 28 14:29:30 PDT 2016


On 3/28/2016 4:58 PM, Reid Kleckner via cfe-dev wrote:
> On Mon, Mar 28, 2016 at 12:43 PM, Edward Diener via cfe-dev
> <cfe-dev at lists.llvm.org
> <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     Does the clang emulation of the VC++ non-standard preprocessor ever
>     occur when clang ( or clang++ ) are invoked as opposed to clang-cl
>     being invoked ?
>
>     Conversely is the macro _MSC_VER ever predefined when clang ( or
>     clang++ ) are invoked as opposed to clang-cl being invoked ?
>
>     I am hoping the answer to both questions above is 'no', but if it is
>     not I need to know what the exceptions are and why.
>
>
> Well, the answer to both is "yes". Essentially, the non-standard
> pre-processor behavior is enabled when clang is targeting an MSVC
> environment. This can happen if you run 'clang
> --target=x86_64-windows-msvc', for example. The good news is that
> _MSC_VER should always be defined when we are doing non-standard things,
> so you can use that as a feature test.
>
> It is technically possible for the user to invoke clang in a way that
> enables MSVC pre-processor quirks without defining _MSC_VER, but that is
> not expected to work with code in the wild.
>
> I tried to update or (poor) documentation on our flags here:
> http://clang.llvm.org/docs/UsersManual.html#microsoft-extensions
> It doesn't discuss pre-processor changes, unfortunately. I've forgotten
> what the even are.

Thanks for your explanation. I will, for all intents and purposes, use 
_MSC_VER to indicate by clang that the non-standard preprocessor 
behavior is in effect no matter if clang, clang++, or clang-cl is 
invoked in Windows.





More information about the cfe-dev mailing list