aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Melnikov <emilmelnikov@users.noreply.github.com>2024-05-29 16:04:44 +0200
committerEli Schwartz <eschwartz93@gmail.com>2024-05-31 08:35:28 -0400
commit8603bb491925d9cb74f63725e02fab2a0c6fafe1 (patch)
treeb4a4c30e4c7af13246605d4bde1d8369bcb72ed2
parentd9e3a3f09ff82fafab85f1d8631c9e8689850510 (diff)
downloadmeson-8603bb491925d9cb74f63725e02fab2a0c6fafe1.zip
meson-8603bb491925d9cb74f63725e02fab2a0c6fafe1.tar.gz
meson-8603bb491925d9cb74f63725e02fab2a0c6fafe1.tar.bz2
Explain how to add preprocessor defines in FAQ.md
See https://github.com/mesonbuild/meson/issues/6269 for the discussion. Co-authored-by: Eli Schwartz <eschwartz93@gmail.com>
-rw-r--r--docs/markdown/FAQ.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/markdown/FAQ.md b/docs/markdown/FAQ.md
index ffc9e17..810e9da 100644
--- a/docs/markdown/FAQ.md
+++ b/docs/markdown/FAQ.md
@@ -695,3 +695,16 @@ directory. It glob ignores ```"*"```, since all generated files should not be
checked into git.
Users of older versions of Meson may need to set up ignore files themselves.
+
+## How to add preprocessor defines to a target?
+
+Just add `-DFOO` to `c_args` or `cpp_args`. This works for all known compilers.
+
+```meson
+mylib = library('mylib', 'mysource.c', c_args: ['-DFOO'])
+```
+
+Even though [MSVC documentation](https://learn.microsoft.com/en-us/cpp/build/reference/d-preprocessor-definitions)
+uses `/D` for preprocessor defines, its [command-line syntax](https://learn.microsoft.com/en-us/cpp/build/reference/compiler-command-line-syntax)
+accepts `-` instead of `/`.
+It's not necessary to treat preprocessor defines specially in Meson ([GH-6269](https://github.com/mesonbuild/meson/issues/6269#issuecomment-560003922)).