[cfe-dev] [llvm-dev] problem (and fix) with -fms-extensions
Marc Espie via cfe-dev
cfe-dev at lists.llvm.org
Wed May 17 16:35:43 PDT 2017
On Wed, May 17, 2017 at 03:55:06PM -0700, Reid Kleckner wrote:
>
> On Wed, May 17, 2017 at 3:22 PM, Marc Espie <[1]espie at nerim.net> wrote:
>
> On Wed, May 17, 2017 at 01:01:07PM -0700, Reid Kleckner wrote:
> >
> >Â Â I'd rather not add new pre-defined macros if we can avoid it.
> There are
> >Â Â already too many. You can probably detect this situation
> with:
> >Â Â #if defined(_MSC_EXTENSIONS) && !defined(_WCHAR_T_DEFINED)
> >
> Was this added recently ?
> There is no _MSC_EXTENSIONS in the clang I'm using...
>
> Looks like we only define it for Windows targets.
> How about __is_identifier?
Or, what's the problem with moving _MSC_EXTENSIONS to be for all targets.
Look, this stuff is highly specific, I doubt many people are going to
use -fms-extensions who don't know what they're doing.
E.g., the exposure to _MSC_EXTENSIONS will be minimal.
Having a single define will mean replacing (for us)
#ifndef __cplusplus
typedef int __wchar_t;
#endif
with
#if !defined(__cplusplus) && !defined(_MSC_EXTENSIONS)
typedef int __wchar_t;
#endif
which is fairly acceptable.
Playing with __is_identifier is rather more awful, because there is no
simple construct, we can't simply write:
#if !defined(__cplusplus) || __is_identifier(__wchar_t)
because this *also* has to work with other compilers, some of which
do not understand __is_identifier at all, so it can't be a single test
then.
It would become some atrocity like
#if !defined(__cplusplus)
# if defined(__is_identifier)
# if __is_identifier(__wchar_t)
# else
typedef int __wchar_t;
# endif
# else
typedef int __wchar_t;
# endif
#endif
And that has about zero chance to ever be committed in our tree,
especially since this is in a md _types.h file, so this construct x10 times
in the tree.
More information about the cfe-dev
mailing list