#ifdef _JBLEN not portable
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Wed Jun 24 15:27:00 GMT 1998
> From: grahams@rcp.co.uk
>
> Hi
>
> The use of "#ifdef _JBLEN" in toplev.h to determine if jmp_buf is
> defined is not portable. On my x86-linux + glibc-2.0.6 system setjmp.h
> is included before toplev.h and yet the prototype for
> set_float_handler() is excluded because _JBLEN is not defined.
>
> This means that files which use set_float_handler() and include both
> setjmp.h and toplev.h do not always see a prototype for
> set_float_handler depening on whether setjmp.h defines _JBLEN
>
> This problem occurs anytime a system dependent define (here I am
> refering to the name and not what its defined as) to conditionalise
> the inclusion of a prototype.all define is used
>
> Any suggestion onto how to elimate this system dependency. Here are
> some to start with
>
> 1. include <setjmp.h> in toplev.h so jmpbuf is always defined.
>
> This probably goes against egcs coding standards
>
> 2. move setjmp stuff to system.h
Since both toplev.h and system.h are included in almost every
file, choices 1&2 would both end up doing the same thing. That is,
every C file would get setjmp.h. Some egcs developers don't like it
when a header only needed in a couple of files gets included
everywhere, so I'd like to shy away from these solutions.
> 3. include <setjmp.h> indirectly via a egcs specific include files
> which also egcs specific define "HAS_SETJMPBUF" or
> whatever.
>
> Graham
Choice #3 would work, but IMHO its kind of overkill for this
problem and introduces extra of hair. :-)
A lower impact alternative would be to find a macro defined in glibc's
setjmp.h and change the test in toplev.h to check _JBLEN as well as
this new one which you could choose for us. Eg:
> #if defined(_JBLEN) || defined(<SOMETHING_DEFINED_IN_GLIBC_SETJMP_H>)
> extern void set_float_handler PROTO((jmp_buf));
> #endif
Another alternative would be to forgo the prototype argument when
setjmp.h doesn't define _JBLEN. Eg:
> #ifdef _JBLEN
> extern void set_float_handler PROTO((jmp_buf));
> #else
> extern void set_float_handler ();
> #endif
I much prefer the first solution since it gets us the proto
argument. The second one just papers over it.
--Kaveh
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu Icon CMT Corp.
More information about the Gcc-bugs
mailing list