mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-22 23:58:48 -05:00
Add STATIC_ASSERT() macro and use it
This commit is contained in:
parent
c56d7fe0eb
commit
688556a5d1
@ -38,4 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
C(const C &); \
|
C(const C &); \
|
||||||
C &operator=(const C &)
|
C &operator=(const C &)
|
||||||
|
|
||||||
|
// Fail compilation if condition expr is not met.
|
||||||
|
// Note that 'msg' must follow the format of a valid identifier, e.g.
|
||||||
|
// STATIC_ASSERT(sizeof(foobar_t) == 40), foobar_t_is_wrong_size);
|
||||||
|
#define STATIC_ASSERT(expr, msg) typedef char msg[!!(expr) * 2 - 1]
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -135,7 +135,8 @@ class AndroidSystemLogOutput : public ICombinedLogOutput {
|
|||||||
}
|
}
|
||||||
void logRaw(LogLevel lev, const std::string &line)
|
void logRaw(LogLevel lev, const std::string &line)
|
||||||
{
|
{
|
||||||
assert(ARRLEN(g_level_to_android) == LL_MAX);
|
STATIC_ASSERT(ARRLEN(g_level_to_android) == LL_MAX,
|
||||||
|
mismatch_between_android_and_internal_loglevels);
|
||||||
__android_log_print(g_level_to_android[lev],
|
__android_log_print(g_level_to_android[lev],
|
||||||
PROJECT_NAME_C, "%s", line.c_str());
|
PROJECT_NAME_C, "%s", line.c_str());
|
||||||
}
|
}
|
||||||
@ -228,7 +229,8 @@ const std::string Logger::getLevelLabel(LogLevel lev)
|
|||||||
"VERBOSE",
|
"VERBOSE",
|
||||||
};
|
};
|
||||||
assert(lev < LL_MAX && lev >= 0);
|
assert(lev < LL_MAX && lev >= 0);
|
||||||
assert(ARRLEN(names) == LL_MAX);
|
STATIC_ASSERT(ARRLEN(names) == LL_MAX,
|
||||||
|
mismatch_between_loglevel_names_and_enum);
|
||||||
return names[lev];
|
return names[lev];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user