D
David
I am compiling C++ under both MacOsX and under Bloodshed Dev C++ on
Windows XP. Because the console window disappears under Bloodshed when
using the standard assert() via
#include <cassert>
I wrote my own "asserting.h", which goes as follows:
=============================================
#include <iostream>
#include <cstdlib>
#define asserting(e) \
if (!(e)) {\
std::cout << " assertion " << #e << " fails" << endl \
<< "File:" << __FILE__ << " line: " << __LINE__ << endl \
<< " aborting " << endl;\
getchar();\
abort();\
}//getchar() stops the console window disappearing before it can be
read
==============================================
This works partially, but it doesn't core dump when compiled with a
main statement asserting(0==1). Compiled with g++ -Wall -pedantic
-ansi. More precisely, I looked for a file with "core" as part of its
name, and couldn't find one. Does core dumping happen only if one
compiles with a debug flag? There seem to be many alternative debug
flags and I can't understand the manual explaining them. Which debug
flag should be used? Why does the standard assert.h define two macros
assert and __assert? What does one gain by this complication?
Suggestions for improvements to my code welcomed.
Windows XP. Because the console window disappears under Bloodshed when
using the standard assert() via
#include <cassert>
I wrote my own "asserting.h", which goes as follows:
=============================================
#include <iostream>
#include <cstdlib>
#define asserting(e) \
if (!(e)) {\
std::cout << " assertion " << #e << " fails" << endl \
<< "File:" << __FILE__ << " line: " << __LINE__ << endl \
<< " aborting " << endl;\
getchar();\
abort();\
}//getchar() stops the console window disappearing before it can be
read
==============================================
This works partially, but it doesn't core dump when compiled with a
main statement asserting(0==1). Compiled with g++ -Wall -pedantic
-ansi. More precisely, I looked for a file with "core" as part of its
name, and couldn't find one. Does core dumping happen only if one
compiles with a debug flag? There seem to be many alternative debug
flags and I can't understand the manual explaining them. Which debug
flag should be used? Why does the standard assert.h define two macros
assert and __assert? What does one gain by this complication?
Suggestions for improvements to my code welcomed.