[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)
Jon Roelofs via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 12:40:28 PST 2023
================
@@ -1344,6 +1344,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (TI.getTriple().isOSBinFormatELF())
Builder.defineMacro("__ELF__");
+ // Target OS macro definitions.
+ if (PPOpts.DefineTargetOSMacros) {
+ const llvm::Triple &Triple = TI.getTriple();
+#define TARGET_OS(Name, Predicate) \
+ Builder.defineMacro(#Name, Predicate ? "1" : "0");
----------------
jroelofs wrote:
`Predicate` should be in parens to make the precedence explicit in the face of preprocessor expansion.
https://github.com/llvm/llvm-project/pull/74676
More information about the cfe-commits
mailing list