[previous] 1038 [next] [E] The sequence ", ##__VA_ARGS__" is a language extension.
Language extensions

Message 1038 is generated when tokens , followed by ## precede the variable argument list __VA_ARGS__ in the replacement list of a macro definition. This is a language extension and is not recognised syntax in ISO:C.

The purpose of the ## token is to require that the preceding comma should be removed if the variable argument list happens to be empty.

In the code example below, the statement "DF ("A message");" actually expands to:
  (void)fprintf (stderr, "A message");
If the ## token is omitted from the macro definition, the statement expands to:
  (void)fprintf (stderr, "A message", );
This would result in syntax errors.


/*PRQA S 336,602,1307,2017,3122,3209,3408,3429,3602,3625 ++*/

#include <stdio.h>

#define DF(format, ...) (void)fprintf (stderr, format, ##__VA_ARGS__)    /* Message 1030 and 1038 */


extern void foo(void)
{
    DF ("A message");                                                    /* Message 0850 1035 and 1036 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents