1 /* Copyright (c) 2005-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
13 #include <xbt/sysdep.h>
14 #include <xbt/virtu.h>
16 /** @addtogroup XBT_ex_c
17 * @brief Exceptions support (C)
19 * Those functions are used to throw C++ exceptions from C code. This feature
20 * should probably be removed in the future because C and exception do not
21 * exactly play nicely together.
26 /** Helper function used to throw exceptions in C */
27 XBT_ATTRIB_NORETURN XBT_PUBLIC void _xbt_throw(char* message, const char* file, int line, const char* func);
29 /** Builds and throws an exception with a printf-like formatted message
33 #define THROW(...) _xbt_throw(bprintf(__VA_ARGS__), __FILE__, __LINE__, __func__)
35 XBT_ATTRIB_NORETURN void xbt_throw_impossible(const char* file, int line, const char* func);
36 /** Throw an exception because something impossible happened
39 #define THROW_IMPOSSIBLE xbt_throw_impossible(__FILE__, __LINE__, __func__)
41 /** Throw an exception because something unimplemented stuff has been attempted
44 XBT_ATTRIB_NORETURN XBT_PUBLIC void xbt_throw_unimplemented(const char* file, int line, const char* func);
45 #define THROW_UNIMPLEMENTED xbt_throw_unimplemented(__FILE__, __LINE__, __func__)
47 /** Die because something impossible happened
50 #define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)")