[mercury-users] MGNUC: problem with missing macros definitions

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Sun Dec 16 04:26:49 AEDT 2001


I need to call Mercury from C++. I used the
samples/cplusplus_calls_mercury and it works great, but the whole process
of compilation is kind of black box to me.

Let's speak about the sample itself, cplusplus_calls_mercury.

I would like to use the strdup() function in my C++ code, let's say in
cpp_main.cc in the sample. strdup() is defined in string.h, so I expected
that #include <string.h> will help the compiler to find strdup()

Unfortunately, the string.h defines strdup() only
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED

If I write a hello-world application that uses strdup, #include <string.h>
and compile it with "gcc -o hello hello.c", everything works well, since
macros __USE_SVID and __USE_BSD are defined.

If I use the Mmakefile in the samples directory to build cpp_main.o with
MGNUC, it fails, since MGNUC doesn't define any of the required macros.

Also, adding -D__USE_BSD (for example) to MGNUCFLAGS won't help. Mgnuc
for whatever reason calls gcc more than once and passes the -D only in the
first run.

(And naturally, using default gcc to compile cpp_main.cc from the sample
is not a good idea, since I need to use Mercury as well.)

What should I modify to make this work?

I expect similar problem to occur anytime in anything, so is there a
manual on gcc and standard libraries and their options that I could read?

Thanks for help, Andrew.

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