[m-dev.] diff: pragma c_code fix
Tyson Dowd
trd at cs.mu.OZ.AU
Fri Nov 10 12:21:05 AEDT 2000
On 09-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> Hi,
>
>
> ===================================================================
>
>
> Estimated hours taken: 1
>
> mercury/compiler/llds_out.m:
> Output any `pragma c_code' first for the LLDS backend. This is
> because variables may be defined in a `pragma c_code' and we want
> the definition to appear before any use of the variable. Also
> output the `pragma c_code' fragments in the same order they appear
> in the source file, as this is the more intuitive behaviour.
I don't think this is the right approach to take. In fact, I think this
is broken.
If you want to declare variables in the c_code that can be referenced
from any place in the module, use pragma c_header_code, and put an
extern declaration in for the variable. Declarations should go in the
c_header code, definitions in c_code. (Perhaps the documentation should
be clearer on this issue?).
Then it doesn't matter *where* you put the actual definition of the
variable.
That way you can use --split-c-files and even if every procedure is put
in a separate file, they can all see the c_header_code, and know there
will be a variable defined somewhere to link to.
Your change will just hide this problem -- the code will work fine when
in a single file but cannot be split into separate files without
breaking.
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list