mirror of
https://github.com/darlinghq/ctest.git
synced 2025-03-04 13:57:43 +00:00
Refactor pragma's for warning control
This commit is contained in:
parent
0982423706
commit
a900b3b3c7
38
ctest.h
38
ctest.h
@ -40,10 +40,29 @@
|
||||
typedef void (*ctest_setup_func)(void*);
|
||||
typedef void (*ctest_teardown_func)(void*);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
||||
#define CTEST_IMPL_PRAGMA(x) _Pragma (#x)
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if (defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
|
||||
/* the GCC argument will work for both gcc and clang */
|
||||
#define CTEST_IMPL_DIAG_PUSH_IGNORED(w) \
|
||||
CTEST_IMPL_PRAGMA(GCC diagnostic push) \
|
||||
CTEST_IMPL_PRAGMA(GCC diagnostic ignored "-W" #w)
|
||||
#define CTEST_IMPL_DIAG_POP() \
|
||||
CTEST_IMPL_PRAGMA(GCC diagnostic pop)
|
||||
#else
|
||||
/* the push/pop functionality wasn't in gcc until 4.6, fallback to "ignored" */
|
||||
#define CTEST_IMPL_DIAG_PUSH_IGNORED(w) \
|
||||
CTEST_IMPL_PRAGMA(GCC diagnostic ignored "-W" #w)
|
||||
#define CTEST_IMPL_DIAG_POP()
|
||||
#endif
|
||||
#else
|
||||
/* leave them out entirely for non-GNUC compilers */
|
||||
#define CTEST_IMPL_DIAG_PUSH_IGNORED(w)
|
||||
#define CTEST_IMPL_DIAG_POP()
|
||||
#endif
|
||||
|
||||
CTEST_IMPL_DIAG_PUSH_IGNORED(strict-prototypes)
|
||||
|
||||
struct ctest {
|
||||
const char* ssname; // suite name
|
||||
@ -59,9 +78,7 @@ struct ctest {
|
||||
unsigned int magic;
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
CTEST_IMPL_DIAG_POP()
|
||||
|
||||
#define CTEST_IMPL_NAME(name) ctest_##name
|
||||
#define CTEST_IMPL_FNAME(sname, tname) CTEST_IMPL_NAME(sname##_##tname##_run)
|
||||
@ -269,10 +286,7 @@ void CTEST_LOG(const char* fmt, ...)
|
||||
msg_end();
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
|
||||
#endif
|
||||
CTEST_IMPL_DIAG_PUSH_IGNORED(missing-noreturn)
|
||||
|
||||
void CTEST_ERR(const char* fmt, ...)
|
||||
{
|
||||
@ -287,9 +301,7 @@ void CTEST_ERR(const char* fmt, ...)
|
||||
longjmp(ctest_err, 1);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
CTEST_IMPL_DIAG_POP()
|
||||
|
||||
void assert_str(const char* exp, const char* real, const char* caller, int line) {
|
||||
if ((exp == NULL && real != NULL) ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user