Since we're already using `vsnprintf` and other C99 features, it's only
natural to use `snprintf` as well. Moreover, `sprintf` is "deprecated" in
Microsoft's CRT in favor of more secure (Microsoft-specific) alternatives
with its use resulting in a warning, while `snprintf` isn't (although
requires recent enough CRT).
Where GCC and Clang issue warnings such as "empty struct is a GNU extension"
(with `-Wgnu-empty-struct`) or "empty struct has size 0 in C, size 1 in C++"
(with `-Wc++-compat`), MSVC issues an error C2016 "C requires that a struct
or union has at least one member".
This eliminates "redundant redeclaration of '..._setup' [-Wredundant-decls]"
and "redundant redeclaration of '..._teardown' [-Wredundant-decls]" GCC
warnings.
Where not possible (as with `ctest::run`), suppress the warning.
This eliminates "function declaration isn't a prototype [-Wstrict-prototypes]"
GCC warning.
This eliminates "function '...' can never be inlined because it uses variable
argument lists [-Winline]" and "inlining failed in call to '...': function
not inlinable [-Winline]" GCC warnings.
Marking `CTEST_ERR` function as noreturn leads to same warning appearing
for `ctest_fail` function; marking the latter as noreturn as well leads
to warnings in user test cases which is not something we want.
This eliminates "function 'CTEST_ERR' could be declared with attribute
'noreturn' [-Wmissing-noreturn]" Clang warning.
This resulted in gaps between `ctest` structs with GCC on amd64, so adding
aligned(1) attribute to the section fix this.
This eliminates "padding struct 'struct ctest' with 4 bytes to align 'data'
[-Wpadded]" and "padding size of 'struct ctest' with 4 bytes to alignment
boundary [-Wpadded]" Clang warnings.
This eliminates "format string is not a string literal [-Wformat-nonliteral]"
(and after that "format specifies type 'void *' but the argument has type
'... *' [-Wformat-pedantic]") Clang warning.
Not using `__attribute__((unused))` as I think the warning could be useful:
if one is using CTEST2, they should be using `data`.
This eliminates "unused parameter '...' [-Wunused-parameter]" GCC/Clang
warning.
Provide prototypes for setup and teardown test case functions as making
them static is not possible due to weak linking.
Provide prototype for ctest_main function as making it static might break
existing code if someone does `#define ctest_main main`.
This eliminates "no previous prototype for function '...'
[-Wmissing-prototypes]" Clang warning.
For that, declare test data structs static and use "used" attribute which
is more appropriate in this case instead of "unused" attribute.
Make use of `__TNAME()` macro instead of explicitly concatenating suite and
test name in two places where above warning was issued along the way.
Use `intmax_t` and `uintmax_t` for signed/unsigned integer assertions.
Previously used `size_t` isn't good enough as we could have 32-bit system
and still be able to work with 64-bit numbers.
Include `<stddef.h>` instead of `<stdio.h>` (which is included under
`CTEST_MAIN` ifdef anyway) to get `size_t` definition.
Use `PRI*` macros instead of `%llu` which may not be supported on some
systems.
Fix a couple of incorrect formatting instances, e.g. when `%d` was used
for line number output, and line number was being (mistakenly? looks like
copy-paste leftovers) casted to `long long` and `unsigned long long`.