On Wed, 27 Dec 2000, Johannes Zellner wrote:

> Hello again,
> 
> xmi sometimes SEGFAULTS in
> 
>     libxmi/display/X/mode.inc:56
> 
> folks!  This is /very/ bad coding style IMHO!

        Systems coding, especially portable system coding, sometimes
requires nasty looking preprocessor magic.  In this case, the preprocessor
stuff provides a way to 'type check' the void* casts at compile time.
Most GGI code does this type of thing.

> XXMI_PRIV() is a threefold preprocessor macro, two times
> casting to another struct and yet using another global
> variable _xmiID.

        Blame the C language with its dumb preprocessor language and lack
of adequate scoping constructs.
 
> If you code like this, you will get bugs for /ever/,
> I'll promise that!

        Yeah, you _do_ tend to pick up a lot of weird bugs in that code,
but the nice thing is that once you have debugged it for one target of one
library, the template format is virtually always going to be the same
across all targets of all libraries.  Just copy that code from a target
you _know_ works and has the same private-data struct system layout as
your target.
 
> How would you expect me to debug crap like this ?

        You shouldn't have to, if you cut and paste from a known working
target.

Jon

---
'Cloning and the reprogramming of DNA is the first serious step in 
becoming one with God.'
        - Scientist G. Richard Seed

Reply via email to