I convert ADD_ADDR(@addr, 192,168,3, 1) into
#define IP_NET 192,168,3
ADD_ADDR(@addr, IP_NET, 1)
and get 'ADD_ADDR is undefined'
Are you sure? Perhaps your compiler says that ADD_ADDR cannot be
called with three arguments?
IP_NET is a single macro argument. It is identified as the second
argument of the macro call, and only then does expansion take
which produces the commas.
To fix this you have to make a three-argument ADD_ADDR.
Consider this example:
#define abc(A, B, C) f(A, B, C)
#define xy(X, Y) abc(X, Y)
#define two3 2, 3
xy(1, two3)
Expansion with gcc's preprocessor, from the shell:
$ gcc -E macro.c
# 1 "macro.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "macro.c"
f(1, 2, 3)
(That doesn't prove it's standard or correct, of course; it's just
a confidence-improving test case.)
As you can see, the xy(X, Y) macro serves as a two-argument interface
to the abc macro. Y is expected to be some item that expands to
a two-element comma separated list.