Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» "static_warning"
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 8, 2024
1 parent a3c78c4 commit 0829a51
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
// Warnings! Located here so they will appear just once in the build output.
//

// static_warning works like a static_assert but only emits a (messy) warning.
#ifdef __GNUC__
namespace mfwarn {
struct true_type {};
struct false_type {};
template <int test> struct converter : public true_type {};
template <> struct converter<0> : public false_type {};
}
#define static_warning(cond, msg) \
struct CAT(static_warning, __LINE__) { \
void _(::mfwarn::false_type const&) __attribute__((deprecated(msg))) {}; \
void _(::mfwarn::true_type const&) {}; \
CAT(static_warning, __LINE__)() {_(::mfwarn::converter<(cond)>());} \
}
#else
#define static_warning(...)
#endif

#if ENABLED(MARLIN_DEV_MODE)
#warning "WARNING! Disable MARLIN_DEV_MODE for the final build!"
#ifdef __LONG_MAX__
Expand Down

0 comments on commit 0829a51

Please sign in to comment.