[mercury-users] foreign_decl vs. foreign_code

Michael Day mikeday at bigpond.net.au
Tue Feb 12 17:29:21 AEDT 2002

> I believe this piece of documentation is wrong, this is not true.
> Entities declared in foreign_code might not be visible at all.

In that case, I'm very confused. Consider this:

typedef int myInt;

myInt g;

void foo() { g = 1; }

How would you encapsulate it in a Mercury module? I originally assumed
that the typedef and variable definition would belong in a foreign_decl
and the foo as a foreign_proc. However this caused duplicate definitions
of g when compiling in hlc.gc. So I placed the typedef in a foreign_decl
and the variable in foreign_code, but this caused the variable to be
invisible to the foreign_proc when compiling in asm_fast.gc. Should I have
put something like "extern myInt g;" in the foreign_decl? Would this be a
problem if g was actually static, to avoid conflicts with other modules?


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