[m-dev.] for review: add MC++ implementation of library and runtime

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 5 22:57:19 AEDT 2000


On 05-Dec-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> [Pete wrote:]
> > > +:- pragma foreign_decl("MC++", "
> > > +/* The `#ifndef ... #define ... #endif' guards against multiple inclusion */
> > 
> > Is there a reasone why this isn't done automatically?
> 
> Not my code, I just copied it from the C version.
> 
> I could probably fix it, but since I didn't really understand why it was
> there in the first place...

The Mercury compiler currently generates code which may include the
declarations from `c_header_code' / `foreign_decl' pragmas more than
once.

The basic issue here is that C doesn't let you define certain
things (e.g. typedefs) twice.  If you have such code that might
get included more than once, it needs to be protected against
such inclusion with an #ifdef ... #define ... #endif guard,
to avoid errors from the C compiler.

C++ allows duplicate typedef definitions, but doesn't allow
duplicate enum definitions, so the same issue applies in C++ too.

Pete's suggestion of doing the header guard automatically is probably
a good idea, but is something that should be a separate change.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list