[mercury-users] Strange C++ compilation problem

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Aug 23 11:43:56 AEST 2002


On 22-Aug-2002, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> I try to compile a C++ code that depends on Mercury code as well.
> The core dependencies of files are:
> 
> goal: db_cint.o
> 
> db_cint.o: db_cint.cc
> db_cint.cc: db_cint.h
> db_cint.h: db_mint.h seznam.h

Incidentally, this dependency is wrong.  The `.cc' file doesn't depend on
the `.h' file, only the `.o' file depends on the `.h' files.  So it should
be like this:

	db_cint.o: db_cint.cc db_cint.h db_mint.h seznam.h

> In file included from db_cint.h:29,
>                  from db_cint.cc:2:
> ../milan/seznam.h:49: ANSI C++ forbids declaration `CHandlSeznam' with no type
> ../milan/seznam.h:49: ANSI C++ forbids data member `CHandlSeznam' with same name as enclosing class
...
> ../milan/veta.h:1092: confused by earlier errors, bailing out

The problem here is that you were #including "seznam.h", which includes
C++ class definitions, inside the scope of `extern "C"'.

According to the C++ standard, this should be legal (see 7.5 paragraph 4),
but GNU C++ 2.95 does not support it.  The "confused by earlier errors,
bailing out" message indicates that GNU C++ got an internal compiler error,
but because some (bogus) error messages were printed out earlier, it
does not report the internal compiler error, but instead just sweeps the
mess under the rug.

Anyway, the fix is to move any #include statements which include C++
header files outside the scope of `extern "C" { ... }' blocks.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list