[MLton] symbol visibility

Wesley W. Terpstra wesley at terpstra.ca
Sat Sep 6 03:28:52 PDT 2008


On Fri, Sep 5, 2008 at 11:20 PM, Matthew Fluet <fluet at tti-c.org> wrote:

> I do think the 'private/public/external' seem a little nicer.


Committed.


>
>  Regarding the MLLIB_{PRIVATE/PUBLIC/whatever} macros, somehow what I'd
>> really like to do is define them based on if the header is used by C-code
>> within the library or C-code outside the library, eg:
>>
>> #ifdef PART_OF_LIBRARY_<NAME-OF-LIBRARY>
>> #define MLLIB_PRIVATE(x) PRIVATE x
>> #define MLLIB_PUBLIC(x) PUBLIC x
>> #else
>> #define MLLIB_PRIVATE(x)
>> #define MLLIB_PUBLIC(x) EXTERNAL x
>> #endif
>>
>> MLLIB_PRIVATE(int foo();)
>> MLLIB_PUBLIC(int bar();)
>>
>> #undef MLLIB_PRIVATE
>> #undef MLLIB_PUBLIC
>>
>> This would then need inclusion (or inline-copy) of exports.h.
>>
>> A user using FFI as pary of his library would then do this:
>> #define PART_OF_LIBRARY_FOO
>> #include "foo.h"
>>
>> Meanwhile, anyone using libfoo would just do:
>> #include "foo.h"
>>
>> Thoughts?
>>
>
> Seems reasonable.  The '#define PART_OF_LIBRARY_FOO' idiom would only be
> needed if the library required a C proxy that itself required access to the
> _export-ed functions of the SML library ---  a sufficiently complex and rare
> situtation that the extra syntax seems fine.
>

Hmm that reasoning suggests to make the #ifdef PART_OF_LIBRARY_XXX into #if
1 when Control.Format = Executable. Done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton/attachments/20080906/7cea044a/attachment.html


More information about the MLton mailing list