[m-dev.] for review: Avoid including mercury_imp.h in generated .h files.

Tyson Dowd trd at cs.mu.OZ.AU
Mon Aug 24 13:45:31 AEST 1998


On 24-Aug-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 20-Aug-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > Hi,
> > 
> > Anyone interested can review this.
> > 
> > It's not exactly a critical change, but it makes things easier to manage
> > when interfacing with C++, and doesn't really do any harm otherwise.
> > 
> > ===================================================================
> > 
> > 
> > Estimated hours taken: 0.75
> > 
> > Allow the #include "mercury_imp.h" in generated header files to be
> > avoided (#define MERCURY_IMP_H isn't quite enough because it will still
> > look for mercury_imp.h in the include path).
> > 
> > We need this because we want to use these prototypes in C++, but don't
> > want to start including the Mercury header files (in fact, I'd prefer
> > to keep the include paths quite separate).
> >
> > compiler/export.m:
> > 	Generate
> > 
> > 	#ifndef MERCURY_EXCLUDE_IMP_H
> > 	#include "mercury_imp.h"
> > 	#endif
> > 
> > 	in the generated .h file for exported Mercury predicates.
> 
> Hmm...
> 
> "mercury_imp.h" or at least "mercury_types.h" is needed
> for the types `Integer', `Float', etc. that may be included in the
> generated header files.  If `MERCURY_EXCLUDE_IMP_H' is defined,
> then these symbols will be undefined, which will lead to compile errors.
> 
> Did I miss something?

Imagine foo.h is a generated .h file.

- You can include foo.h in your C++, but it will complain that it cannot
  find mercury_imp.h, so you will have to put an include path into your
  g++ compile command.  But this is installation-dependent, so you can't
  do it in general very easily. 

- mercury_types.h might be what you want, but mercury_imp.h includes
  everything, including register defintions, which we most certainly
  don't want. So to get rid of the register defintions, you can use
  another hack with -DBLAH_REGS_H.

So you come down to a choice between turning mercury_imp.h off and
adding a few #defines by hand to get things working, and adding a lot of
complexity to your application which wants to use C++.

A better solution is to support compiling C++ using mmake, which sets
the include paths and -D options for you.  But for the application I
am thinking of, there simply isn't enough time to muck around with
such things.

This change is sub-optimal, but doesn't do much harm if you don't use
it.

-- 
Those who would give up essential liberty to purchase a little temporary
safety deserve neither liberty nor safety.     - Benjamin Franklin

Tyson Dowd   <tyson at tyse.net>   http://tyse.net



More information about the developers mailing list