environ

Stephen Weeks MLton@research.nj.nec.com
Fri, 5 Nov 1999 12:32:36 -0800 (PST)


> Don't ask... I have tried renaming environ to environment, but
> then the linker complains about an unresolved reference...
> Is there somewhere else I need to modity, than in src/runtime
> and include ?
> 
> If environ is something compiler specific you're using,
> then I should perhaps just rename the environ field in
> the MLTON_state struct to environment and leave the
> extern ... alone, and use state->environment = environ; ?

environ is used to implement Posix.ProcEnv.environ, so it is
definitely Posix specific.  See basis-library/posix/primitive.sml for
the reference to the C variable "mltonState.environ" and
basis-library/posix/proc-env.sml for the use.

To eliminate the unresolved reference, you need to change the _prim
declaration for environ in primitive.sml to "mltonState.environment"
(and reprocess the basis library - to do this, run "make
../lib/world.mlton" in the src directory).  Now, MLton will spit out
mltonState.environment instead of mltonState.environ.

I'm still somewhat surprised that Posix.ProcEnv.environ was used by
your program at all.  If it wasn't then the dead code elimination
should have removed it and it should never have appeared in the C.
Perhaps there is another problem.