[mercury-users] Problem with linking bigger project (Mercury and C++)

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Mon Jan 7 09:14:37 AEDT 2002


Thanks for assistance. Meanwhile, I really changed the calling scheme, so
that main() is generated by Mercury and later on calls cpp_main() and it
works fine.

A new problem seemed to aris: how to get command-line arguments in Mercury
(and how to pass them to cpp_main), but I've found it in
samples/diff/diff.m.

On Mon, 7 Jan 2002, Fergus Henderson wrote:
> >     /* Inicializace enginu Mercury */
> >     mercury_init(0, NULL, &dummy);
>
> Declaring `char dummy' here is wrong.  `char dummy', whose address
> indicates the top-of-the-stack, should not be declared in a function
> which returns before the Mercury procedures are called.
>
> `char dummy' should be declared in main() [or some other function whose
> stack frame sticks around while the Mercury procedures are being called]
> and should be passed down to komplexne_inicializuj(), perhaps via a global
> variable.
>
> That may solve your segmentation violation problem.

I guess this would help.

It ought to be written somewhere -- in the sample, in the docs.

Thanks a lot.

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