Re: Type checking



On Thu, 2010-03-18 at 07:30 +0200, Kalle Vahlman wrote:

> > the G_TYPE_CHECK_INSTANCE_TYPE() macro won't be disabled - ever. the
> > only way to disable that particular type check is to compile with
> > -DG_DISABLE_CHECKS, which disables g_return_*() -- and you don't really
> > want to do that.
> 
> That's actually "you can't really do that", disabling checks (or to be
> exact, using --disable-debug) would be nice enough for eg. embedded
> systems, but since applications (and libraries) tend to regularly feed
> invalid arguments to libraries and trust the library to handle it all
> you get from it is crashing applications. Even gio was broken wrt
> this: https://bugzilla.gnome.org/show_bug.cgi?id=593856
> 
> It's kind of a sad situation. :(

that's different: --disable-debug (or --enable-debug=no) also adds
-DG_DISABLE_ASSERT which you really, *really* don't want to do.

using --enable-debug=minimum (which disables cast checks) and manually
adding -DG_DISABLE_CHECKS to the CPPFLAGS should be enough for embedded
environments.

CAVEAT: I'm not advocating package maintainers on embedded systems to
use --enable-debug=no *ever*, unless:

  • they audit all the code compiled beforehand
  • they come up with numbers that demonstrate the advantages of
disabling the type checking layer against the potential failures

in all other cases, running with --enable-debug=no is Just Plain Wrong™.
been there, done that.

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]