Page 1 of 1

assert(0) not working in 1.4.0 ?

Posted: Wed Jan 13, 2010 12:48 pm
by a128
It seems that

Code: Select all

#include <assert.h>

//did I need this to show the assert(0)?!!!
consoleDemoInit();
	
assert(0);
is not working anymore..I know that this worked before

Re: assert(0) not working in 1.4.0 ?

Posted: Wed Jan 13, 2010 4:13 pm
by vuurrobin
maybe you're confusing assert with libnds's sassert().

http://libnds.devkitpro.org/a00097.html

I suggest you try that.

Re: assert(0) not working in 1.4.0 ?

Posted: Thu Jan 14, 2010 10:26 am
by a128
vuurrobin wrote:maybe you're confusing assert with libnds's sassert().

http://libnds.devkitpro.org/a00097.html

I suggest you try that.
ok..thanks sassert() is kind of assert() but it takes an additional paramter

assert(0) is ok
sassert(0,"a bug") needs 2 paras

Re: assert(0) not working in 1.4.0 ?

Posted: Tue Jan 19, 2010 8:23 pm
by WinterMute
That's a bit odd, it certainly used to work. Can you file that as a bug & I'll take a look when I get a chance.

http://sourceforge.net/tracker/?func=de ... tid=668551

Re: assert(0) not working in 1.4.0 ?

Posted: Sun Jul 25, 2010 12:30 pm
by WinterMute
Should have posted a bug report & I might have remembered this much sooner :p

Anyway, there were two things affecting the assert code - 1. Dovoto removed the stderr hook from the default console when he added the debug output redirection which meant that nothing would be output and 2. When I added the exit to menu code more recently the DS would shut down or return to hbmenu on an assertion so you wouldn't have a chance to read it.

This works with latest libnds.

Code: Select all

#include <nds.h>
#include <stdio.h>

#include <assert.h>

// function to pause on exit, called on non zero exit code
void systemErrorExit(int rc) {
	printf("exit with code %d\n",rc);

	while(1) {
		swiWaitForVBlank();
		scanKeys();
		if (keysDown() & KEY_A) break;
	}
	
}

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
	consoleDemoInit();
	
	assert(0);

	while(1) {
		swiWaitForVBlank();
		scanKeys();
		if (keysDown() & KEY_X) break;
	}
	return 42;
}