[m-dev.] for review: add MC++ implementation of library and runtime
Tyson Dowd
trd at cs.mu.OZ.AU
Tue Dec 5 23:13:47 AEDT 2000
On 05-Dec-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 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.
Ok, so that sounds like a plain old bug with the way we handle
c_header_code for the C backends.
It would help if we had some better definitions of what was meant by
c_header_code, and therefore what restrictions it had. E.g. that you
can expect it to only be included once (well, effectively anyway).
I'm not sure why this problem hasn't cropped up before.
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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