g_return
Neil Williams
linux at codehelp.co.uk
Fri Aug 13 10:17:53 EDT 2004
On Friday 13 August 2004 11:25, Neil Williams wrote:
> > I don't see why this should be required. We never
> > set G_LOG_DOMAIN anywhere in our code,
Please try this mini-test program (I saved it as src/engine/test/neiltest.c
and added it to the src/engine/test/Makefile.am):
#include <glib.h>
#include <stdio.h>
#include "gnc-engine.h"
int main(int argc, char** argv)
{
g_message("Neil's test routine for glib\n");
gnc_engine_init(argc, argv);
g_message("engine init done\n");
printf("manual print: missing g_message about engine init done?.\n");
#ifdef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "neiltest"
#endif
gnc_engine_shutdown();
g_message("engine has shut down\n");
printf("manual print: engine shutdown done using redefined G_LOG_DOMAIN.\n");
g_return_val_if_fail((1 == 2), 1);
return 0;
}
The output I get is:
Message: Neil's test routine for glib
manual print: missing g_message about engine init done?.
neiltest-Message: engine has shut down
manual print: engine shutdown done using redefined G_LOG_DOMAIN.
neiltest-CRITICAL **: file neiltest.c line 19 (main): assertion `(1 == 2)'
failed
Note that the second g_message (engine init done) does not print but as soon
as G_LOG_DOMAIN is redefined, the next g_message does print (engine has shut
down) and the g_return assert does display the critical warning.
I've just written this on a Debian unstable box that hasn't even been running
for 2 months, let alone used for GnuCash code. To build the gnc_engine
library to link against, I used a pristine CVS HEAD install, fresh this
morning. I ran autogen as:
./autogen.sh --enable-ofx --enable-opt-style-install --enable-doxygen
--disable-nls --prefix=/opt/gnucash
(Incidentally, I had to use:
cd gnucash/src/engine/
ln -s ./ qof
as QOF is looking for a qof/ subdirectory and the link wasn't in CVS)
The box has no glib-2 installations, just glib-1.2
What do you get with the test program?
> > and it's always worked just
> > fine. Is something, somehow, setting G_DISABLE_CHECKS?
grep G_DISABLE_CHECKS src/*/* returns nothing.
If you remove or comment out the #ifdef, #undef, #define and #endif lines, the
final critical error is not printed, yet the program does return 1 - it does
not proceed on to other code.
Every other test program that I've written today (about 6 so far) using
g_message, g_error and g_return works fine. It is only when I use
gnc_engine_init that the G_LOG_DOMAIN needs to be redefined.
e.g. this short program:
#include <glib.h>
int main(void) {
g_return_val_if_fail((1==2), 55);
return 6;
}
works fine, as expected. Critical error printed, value of 55 returned.
** CRITICAL **: file working.c: line 4 (main): assertion `1==2' failed.
--
Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20040813/8848dd95/attachment.bin
More information about the gnucash-devel
mailing list