[Issue 22953] impossible to test for pragma support

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 29 11:30:57 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22953

--- Comment #2 from Adam D. Ruppe <destructionator at gmail.com> ---
That fails in the event of backported features that didn't bump the version
number (see some in gdc), and in the event of target-specific pragmas, like
`linkerDirective`, which only applies if using a MS-COFF target.

For that one, you can approximate it it with a combination of static if version
> X and version(cruntime_microsoft), but you can target ms-coff with the mingw
runtime too, so this check isn't really correct. If there was a
version(Object_format_COFF) that'd possibly work for this case too but there
isn't one

The best way would be something like __traits(supportsPragma, "") to check it
directly, then you can static if it out.

(though since pragmas are often attached to declarations, that's easier said
than done in general, it'd at least give you the starting point as a reliable
test.)

--


More information about the Digitalmars-d-bugs mailing list