On Tue, 13 Aug 2002, Torsten Mohr wrote:
> Hi Dave, > > thanks for your answer. > > Is there any workaround for variadic macros? Something like: > > #ifdef S_SPLINT_S > extern void tmError(int, char*, ...); > #else > #define tmError(lev, fmt, ...) \ > tmErrorFunc(lev, __FILE__, __LINE__, fmt, __VA_ARGS__) > #endif > > But if i'd check a project with +topuse, i'd get an error. > I think the workaround you have it probably about the best you can do. You can use /*@unused@*/ in the declaration to avoid use warnings. > Also, in a construction like this: > > #ifdef S_SPLINT_S > extern void tmErrorIf(int cond, int lev, char* fmt, ...); > #else > #define tmErrorIf(cond, lev, fmt, ...) \ > do { if(cond) { \ > tmErrorFunc(lev, __FILE__, __LINE__, fmt, __VA_ARGS__); \ > } } while(0) > #endif > > I get an error for "cond" being an int, not a boolean. > Not sure what you mean here --- with the #ifdef you have, splint isn't checking the macro definition at all. If you were checking the if(cond) part, you get a warning (+predboolint) because the if test is not a boolean. > > It would be great if i didn't need these workarounds, will there > be support for variadic macros? > Not something we are likely to have time to anytime soon, I'm afraid. If someone else is energetic, of course, I'd be delighted to incorporate a fix. Best, --- Dave > > With these workarounds, splint is a great tool to check a project, > thanks for that. > > > Best regards, > Torsten. > > > > Hi Torsten, > > > > Splint doesn't support ... in macro definitions. Variadic macros (as used > > in your example) are in ISO C99 though, so they should be supported. > > > > Splint supports gcc's __attribute__ syntax at the level of ignoring it > > (but parsing it without complaint). > > > > --- Dave > > > > On Mon, 12 Aug 2002, Torsten Mohr wrote: > > > Hi, > > > > > > i use gcc and some of its extensions, for example: > > > > > > #define tmError(lev, fmt, ...) \ > > > tmErrorFunc(lev, __FILE__, __LINE__, fmt, __VA_ARGS__) > > > > > > It seems that "+gnuextensions" doesn't enable this syntax. > > > > > > This would also be great for some embedded code that uses > > > extensions like "__attribute__ ((section))". > > > > > > Is there some other way to express the above #define in ANSI C? > > > > > > > > > Best regards, > > > Torsten. >