From 3fc16f05b513f26aa5da614673116074f5d60396 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Wed, 6 Sep 2023 03:12:55 +0200 Subject: Add compiler.has_define Adds a new method to the compiler object, has_define. This makes it possible to check if a preprocessor macro/define is set or not. This is especially helpful if the define in question is empty, for example: #define MESON_EMPTY_DEFINE This would yield the same results as a missing define with the existing get_define method, as it would return an empty string for both cases. Therefore this additional method is needed. --- docs/markdown/snippets/compiler_has_define.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/markdown/snippets/compiler_has_define.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/compiler_has_define.md b/docs/markdown/snippets/compiler_has_define.md new file mode 100644 index 0000000..64de26b --- /dev/null +++ b/docs/markdown/snippets/compiler_has_define.md @@ -0,0 +1,10 @@ +## Compilers now have a `has_define` method + +This method returns true if the given preprocessor symbol is +defined, else false is returned. This is useful is cases where +an empty define has to be distinguished from a non-set one, which +is not possible using `get_define`. + +Additionally it makes intent clearer for code that only needs +to check if a specific define is set at all and does not care +about its value. \ No newline at end of file -- cgit v1.1