aboutsummaryrefslogtreecommitdiff
path: root/pw_preprocessor/public
diff options
context:
space:
mode:
authorWyatt Hepler <hepler@google.com>2020-05-01 15:17:31 -0700
committerCQ Bot Account <commit-bot@chromium.org>2020-05-02 00:14:39 +0000
commit3de97fbcc6b38d71ca90f8383da3604ec0af28ef (patch)
tree8b7b36313cadfab6194b8abce08c709fca5bb3aa /pw_preprocessor/public
parentac5b674531c250ed8ba0a3a78ee04117ca3ef426 (diff)
downloadpigweed-3de97fbcc6b38d71ca90f8383da3604ec0af28ef.tar.gz
pw_log: Remove uses of PW_COMMA_ARGS
- Remove uses of PW_COMMA_ARGS on macro-macro boundaries. PW_COMMA_ARGS doesn't expand as expected when invoking one macro from another. - Expand comment for PW_COMMA_ARGS to indicate that it should not be used when invoking a macro from another macro. It should only be used when the macro expands to C code (e.g. a function call). Bug: 117 Change-Id: I201197f0b4727304cc2dedad40ed2f5b6d02b27e
Diffstat (limited to 'pw_preprocessor/public')
-rw-r--r--pw_preprocessor/public/pw_preprocessor/macro_arg_count.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/pw_preprocessor/public/pw_preprocessor/macro_arg_count.h b/pw_preprocessor/public/pw_preprocessor/macro_arg_count.h
index 852557702..4d704deac 100644
--- a/pw_preprocessor/public/pw_preprocessor/macro_arg_count.h
+++ b/pw_preprocessor/public/pw_preprocessor/macro_arg_count.h
@@ -103,13 +103,18 @@
// Expands to a comma followed by __VA_ARGS__, if __VA_ARGS__ is non-empty.
// Otherwise, expands to nothing. This is useful when calling a function with
// __VA_ARGS__, since it removes the extra comma when no arguments are
-// provided.
+// provided. It must NOT be used when invoking a macro from another macro.
//
// This is a more flexible, standard-compliant version of ##__VA_ARGS__. Unlike
// ##__VA_ARGS__, this can be used to eliminate an unwanted comma when
// __VA_ARGS__ expands to an empty argument because an outer macro was called
// with __VA_ARGS__ instead of ##__VA_ARGS__.
//
+// PW_COMMA_ARGS must NOT be used to conditionally include a comma when invoking
+// a macro from another macro. PW_COMMA_ARGS only functions correctly when the
+// macro expands to C or C++ code! When invoking one macro from another, simply
+// pass __VA_ARGS__.
+//
// This can be used to call variadic functions or provide variadic template
// parameters from a macro. For example:
//