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.

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.


It would be great if i didn't need these workarounds, will there
be support for variadic macros?


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.

Reply via email to