[lug] [OT] g++ error message: declared with an exception specification?
D. Stimits
stimits at attbi.com
Tue Nov 19 22:08:58 MST 2002
Scott Herod wrote:
> On Tue, 19 Nov 2002 rm at fabula.de wrote:
>
>
> >On Tue, Nov 19, 2002 at 10:30:50AM -0700, Scott Herod wrote:
> >
> >>Hello,
> >>
> >>Sorry of the OT post, but this is about the best group of people for it.
> >>
> >>I'm trying to write a bash built-in and compile it with g++. This
> is with
> >>bash 2-05a source from the GNU folk. I'm getting errors like:
> >>
> >>../GNU/bash-2.05a/general.h:187: `sh_intfunc_t' declared with an
> exception
> >>specification
> >
> >Rather silly question: if you compile an extension to a C-Program,
> shouldn't
> >the exported functions be wrapped in 'extern C ...{ ...' ? Exception
> specification
> >smells pretty much like C++-Linking ....
> >
> > ralfd
>
>
>
> I thought that was for going the other way, i.e. allowing a C++
> declaration to be understood by C?
Sounds like semantics. One would create a C++ extension to a C program
by wrapping the C++ in extern "C" so it appears as C...both of you said
the same thing. FYI, I have run into lots of functions that now have
their own C++ prototype in GNU libs that now throw exceptions when they
detect C++, and have best dealt with it by only using the extern "C"
version without the exception throwing. What you observe is a bad sign
that it is a reserved "hidden" symbol. You might try intentionally
declaring everything involved as extern "C", as well as undefining
__cplusplus while in that block.
Incidentally, if you cd to /lib/, and have libnss stuff, try this:
nm libnss*.so | grep "_P[^a-zA-Z]"
Better yet, cd to /usr/include/ and run:
grep -r "_P[^a-zA-Z]" *
D. Stimits, stimits AT attbi.com
>
> At any rate, from the dump with g++ -E I discovered that
> /usr/include/sys/cdefs.h is included which contains a few lines with:
>
>
>
> #undef __P
> #undef __PMT
>
> #ifdef __GNUC__
>
> /* GCC can always grok prototypes. For C++ programs we add throw()
> to help it optimize the function calls. But this works only with
> gcc 2.8.x and egcs. */
> # if defined __cplusplus && __GNUC_PREREQ (2,8)
> # define __THROW throw ()
> # else
> # define __THROW
> # endif
> # define __P(args) args __THROW
>
>
>
> which of course screws up the __P definition previously made in one of the
> bash header files. It also explains that nasty throw(). I suspect that
> there are some other #defines that I need to use to not hit this section
> of code.
>
> Scott
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>
More information about the LUG
mailing list