Hi,
I'm trying to compile ClearSilver on a System i platform.
The compiler is C89 compatible (AFAIK). I am compiling the stuff manually, starting with the util directory. Things which compiled out of the box were
missing.c
neo_err.c
neo_misc.c
rcfs.c
snprintf.c
wildmat.c
Now am trying dict.c but got some errors:
/home/schmidt/clearsilver/util/dict.c, 563.77: CZM0041(20) The invocation
of macro nerr_raise contains fewer arguments than are required by the
macro definition.
The compiler uses C99 style var args.
ILE C Language Reference:
Function-Like Macros
More complex than object-like macros, a function-like macro definition declares the names of formal parameters within parentheses, separated by commas. An empty formal parameter list is legal: such a macro can be used to simulate a function that takes no arguments.
Function-like macro definition: An identifier followed by a parameter list in parentheses and the replacement tokens. The parameters are imbedded in the replacement code. White space cannot separate the identifier (which is the name of the macro) and the left parenthesis of the parameter list. A comma must separate each parameter. For portability, you should not have more than 31 parameters for a macro. The parameter list may end with an ellipsis (...). In this case, the identifier __VA_ARGS__ may appear in the replacement list.
Function-like macro invocation: An identifier followed by a comma-separated list of arguments in parentheses. The number of arguments should match the number of parameters in the macro definition, unless the parameter list in the definition ends with an ellipsis. In this latter case, the number of arguments in the invocation should exceed the number of parameters in the definition. The excess are called trailing arguments. Once the preprocessor identifies a function-like macro invocation, argument substitution takes place. A parameter in the replacement code is replaced by the corresponding argument. If trailing arguments are permitted by the macro definition, they are merged with the intervening commas to replace the identifier __VA_ARGS__, as if they were a single argument. Any macro invocations contained in the argument itself are completely replaced before the argument replaces its corresponding parameter in the replacement code. This language feature is an orthogonal extension of C++.
If the identifier list does not end with an ellipsis, the number of arguments in a macro invocation must be the same as the number of parameters in the corresponding macro definition. During parameter substitution, any arguments remaining after all specified arguments have been substituted (including any separating commas) are combined into one argument called the variable argument. The variable argument will replace any occurrence of the identifier __VA_ARGS__ in the replacement list. The following example illustrates this:
#define debug(...) fprintf(stderr, __VA_ARGS__)
debug("flag"); /* Becomes fprintf(stderr, "flag"); */
I'm not a C programmer and don't understand the following code (which create the error message in the compilation):
dict.c: nerr_raise(NERR_ASSERT, "value or new are NULL");
neo_err.h:
#if defined(USE_C99_VARARG_MACROS)
#define nerr_raise(e , f , ...) \
nerr_raisef(__PRETTY_FUNCTION__ , __FILE__ , __LINE__ , e , f , __VA_ARGS__)
#elif defined(USE_GNUC_VARARG_MACROS)
#define nerr_raise(e,f,a...) \
nerr_raisef(__PRETTY_FUNCTION__,__FILE__,__LINE__,e,f,##a)
#endif
NEOERR *nerr_raisef (const char *func, const char *file, int lineno,
NERR_TYPE error, const char *fmt, ...)
ATTRIBUTE_PRINTF(5,6);
Question: Why is dict.c calling nerr_raise with only 2 parm. Shouldn't it be three parms (error type, format string and error message)? I definitely got something wrong but I don't know what?
The language reference says: ... the number of arguments in the invocation should exceed the number of parameters in the definition ...
Every help is welcome
Thanx in advance
Mihael Schmidt
Anwendungsentwicklung
Dirk Rossmann GmbH
Iserhägener Str.16
30938 Burgwedel
* +49 (05139) 898 - 4353
Handelsregister-Nr. HRB 120546, Amtsgericht Hannover
Ust-Id-Nr. DE 115055186
St.-Nr. 16 / 205 / 65401
Geschäftsführer: Dirk Roßmann, Alice Schardt-Roßmann, Roland Frobel, Klaus Praus