[mercury-users] Re: Compilation errors with Mercury and GTK--

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 2 05:13:49 AEDT 2002


Andy Coates <coates_andy at hotmail.com> writes:
> I'm currently writing a application in C++, using the GTK-- wrappers for 
> GTK.
> I needed to write an NLP module and after reading the documentation and 
> general comments on Mercury I decided to write a simple parser in Mercury 
> and try to integrate it with my existing code.
> 
> I have written said parser, which has the following predicate as its 
> interface:
> :- pred m_parse( list(char)::int, list(char)::out) is cc_multi.
> 
> I then export it like so:
> :- pragma export(m_parse(in, out), "m_parse").
> 
> I then compiled myparser.m into an object file using
> mmc -Ec myparser
> 
> All well and good so far (at least I think so!).
> Within my C++ code;  main.cc includes mercury_imp.h and myparser.h, and i am 
> now trying to compile it all together using g++.
> 
> My problem is that I cannot get the Mercury source and the GTK sources to 
> play nice :(
> 
> I get different compiler errors depending on the order of the #includes in 
> main.cc:
> 
> If I #include the mercury libraries first (as in the examples provided with 
> the distribution) I get a whole load of errors about macro calls made from 
> the GTK source code with too many arguments, and i'm not about to go in and 
> change that code, as it used to compile fine!
> 
> If I include the mercury libraries after I have included <gtk--.h> then g++ 
> complains that mercury_bootstrap.h has a declaration that doesnt actually 
> declare anything!
>
> I don't really want to change the Mercury Source code either, so is there 
> something obvious I haven't tried yet?!
> 
> I then recreated the exact same errors simply by adding
> #include <gtk--.h> to cpp_main.cc in the examples directory, and adding an 
> include path to the Mmakefile.
> 
> if anyone has any suggestions, please let me know.

Try compiling with `-DMR_NO_BACKWARDS_COMPAT' or `-DMERCURY_BOOTSTRAP_H'.

Previous versions of the Mercury header files were not completely
namespace-clean.  This can lead to name clashes if you try to mix
them with other headers that are also not namespace-clean.

The problem is mostly fixed in 0.10.1, but we left a lot of the
problematic names still defined by default, to avoid breaking
existing code which depends on them.  But they can be disable
by defining MR_NO_BACKWARDS_COMPAT or MERCURY_BOOTSTRAP_H.

If that doesn't solve the problem, try building using the latest
release-of-the-day release.  Or try using `--high-level-code'
(in which case you need mercury.h rather than mercury_imp.h).

-- 
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