|
The culprit of CDRIVER-2759 was passing a function with the wrong type to a variadic list. Reading variadic arguments in C is not type safe, so there was no compiler warning/error.
We could do type checking when TestSuite_AddFull is called by wrapping the variadic arguments with no-op function calls using preprocessor defines. E.g. something along the lines of this:
#define TestSuite_AddFull(_suite, _name, _func, _dtor, _ctx, ...) \
|
_TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, FOREACH(TypeCheck, __VA_ARGS__) NULL)
|
|
Where this would expand to:
_TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, TypeCheck(chk1), TypeCheck(chk2), TypeCheck(chk3), null)
|
Therefore, the caller does the type check. We don't have any mechanism for doing a foreach with the preprocessor. See this example and P99_FOR.
|