make trailing ';' mandatory for NS_ASSERT* and NS_FATAL_ERROR macros. fix uses.
--- a/samples/main-debug.cc Wed Feb 21 20:04:32 2007 +0100
+++ b/samples/main-debug.cc Wed Feb 21 20:07:39 2007 +0100
@@ -22,6 +22,6 @@
NS_ASSERT (a == 0);
NS_ASSERT_MSG (a == 0, "my msg");
- NS_ASSERT (a != 0)
+ NS_ASSERT (a != 0);
NS_ASSERT_MSG (a != 0, "my 2 msg");
}
--- a/src/core/assert.h Wed Feb 21 20:04:32 2007 +0100
+++ b/src/core/assert.h Wed Feb 21 20:07:39 2007 +0100
@@ -60,14 +60,19 @@
* unverified condition and halts in the ns3::AssertBreakpoint
* function.
*/
-#define NS_ASSERT(condition) \
- if (!(condition)) \
+#define NS_ASSERT(condition) \
+ do \
{ \
- std::cout << "assert failed. file=" << __FILE__ << \
- ", line=" << __LINE__ << ", cond=\""#condition << \
- "\"" << std::endl; \
- ns3::AssertBreakpoint (); \
- }
+ if (!(condition)) \
+ { \
+ std::cout << "assert failed. file=" << __FILE__ << \
+ ", line=" << __LINE__ << ", cond=\""#condition << \
+ "\"" << std::endl; \
+ ns3::AssertBreakpoint (); \
+ } \
+ } \
+ while (false)
+
/**
* \ingroup assert
@@ -78,12 +83,16 @@
* true, the program prints the message to output and
* halts in the ns3::AssertBreakpoint function.
*/
-#define NS_ASSERT_MSG(condition, message) \
- if (!(condition)) \
- { \
- std::cout << message << std::endl; \
- ns3::AssertBreakpoint (); \
- }
+#define NS_ASSERT_MSG(condition, message) \
+ do \
+ { \
+ if (!(condition)) \
+ { \
+ std::cout << message << std::endl; \
+ ns3::AssertBreakpoint (); \
+ } \
+ } \
+ while (false)
#else /* NS3_ASSERT_ENABLE */
--- a/src/core/fatal-error.h Wed Feb 21 20:04:32 2007 +0100
+++ b/src/core/fatal-error.h Wed Feb 21 20:07:39 2007 +0100
@@ -36,8 +36,12 @@
* builds.
*/
#define NS_FATAL_ERROR(msg) \
- std::cout << msg << std::endl; \
- ns3::AssertBreakpoint ();
+ do \
+ { \
+ std::cout << msg << std::endl; \
+ ns3::AssertBreakpoint (); \
+ } \
+ while (false)
#endif /* FATAL_ERROR_H */