1
0
Fork 0

Add an unconditional debug assertion failure macro

This commit is contained in:
Robbert van der Helm 2022-01-26 20:51:34 +01:00
parent 19b51df357
commit 2614be26ab
2 changed files with 17 additions and 0 deletions

View file

@ -45,6 +45,22 @@ macro_rules! nih_debug_assert {
);
}
/// An unconditional debug assertion failure, for if the condition has already been checked
/// elsewhere.
#[macro_export]
macro_rules! nih_debug_assert_failure {
() => (
if cfg!(debug_assertions) {
nih_log!("Debug assertion failed");
}
);
($format:expr $(, $arg:tt)*) => (
if cfg!(debug_assertions) {
nih_log!(concat!("Debug assertion failed: ", $format) $(, $arg)*);
}
);
}
/// A `debug_assert_eq!()` analogue that prints the error with line number information instead of
/// panicking.
#[macro_export]

View file

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#[macro_use]
pub mod debug;
pub mod params;
pub mod plugin;