[m-dev.] for review: Avoid including mercury_imp.h in generated .h files.
Tyson Dowd
trd at cs.mu.OZ.AU
Sun Aug 30 14:51:57 AEST 1998
On 30-Aug-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 24-Aug-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > 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.
>
> Why not use a solution similar to that used by gcc: have an option (or
> a command) which prints out the installation-dependent path?
> GNU C has an option `-print-libgcc-file-name' which is used for printing
> out the path to libgcc.a. It would be easy to add an option to mgnuc
> to print out the include path for the Mercury runtime's C header files.
> Then you just use
>
> CXX = g++
> CXXFLAGS = -I`mgnuc --print-include-path`
>
> in your Makefile or Mmakefile.
Yep, sounds like a good idea.
> > - mercury_types.h might be what you want,
>
> Yes, indeed I strongly suggest that it *is* what you want.
>
> > but mercury_imp.h includes
> > everything, including register defintions, which we most certainly
> > don't want.
>
> Agreed. So change the generated #include in the generated header file
> to include mercury_types.h instead of mercury_imp.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,
>
> These #defines are also installation-dependent.
> So I don't think this is a good solution.
Not in the long term, no. It was never intended to be.
>
> > 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.
>
> Actually it is `mgnuc' not `mmake' which sets those.
>
> Mmake already supports compiling C++: you just have to add
> appropriate rules to your Mmakefile.
Well, gmake supports compiling C++, mmake just lets you get access
to gmake. Mmake doesn't even mention .cc as a .SUFFIX -- I'm not sure
whether there is some "support" I'm not aware of.
> > But for the application I
> > am thinking of, there simply isn't enough time to muck around with
> > such things.
>
> The change to mgnuc mentioned above would be quite easy.
> The change to mmc to generate `#include "mercury_types"'
> instead of `#include "mercury_imp"' should be trivial.
>
> So how does that sound?
Like a good idea for next week.
--
Tyson Dowd # There isn't any reason why Linux can't be
# implemented as an enterprise computing solution.
trd at cs.mu.oz.au # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.
More information about the developers
mailing list