bjope wrote:

This seems to break something with variadic args and the gcc hack with ## to 
ignore the trailing comma error:

```
#include <stdio.h>
#define debug_ok(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
void foo() {
    debug_ok("qwerty");
}

#define debug_nok(...) fprintf(stderr, "qwerty", ## __VA_ARGS__)
void bar() {
    debug_nok();
}
```

At least with `-std=c23` we get this:
```
<source>:9:5: error: expected expression
    9 |     debug_nok();
      |     ^
<source>:7:64: note: expanded from macro 'debug_nok'
    7 | #define debug_nok(...) fprintf(stderr, "qwerty", ## __VA_ARGS__)
      |                                                                ^
1 error generated.
Compiler returned: 1
```

See godbolt test here: https://godbolt.org/z/fejP1oa1f

But given that there is a difference between the foo and bar tests maybe I've 
missed some special rule for when this variadic macro solution with ## applies.

https://github.com/llvm/llvm-project/pull/125232
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to