Shared library extern (C) variables
Mineko
uminekorox at gmail.com
Sun Jan 5 11:16:35 PST 2014
On Sunday, 5 January 2014 at 19:08:44 UTC, Jeremy DeHaan wrote:
> On Sunday, 5 January 2014 at 18:22:54 UTC, Mineko wrote:
>> I keep getting mixed results searching for this. :\
>>
>> Just as the title says, is it safe to extern (C) variables?
>>
>> Something like this:
>> extern (C) auto foo = 800;
>>
>> And then call that from another program?
>>
>> Also, just because this has been bugging me for a while.. Is
>> export broken, or it it not supposed to be used the same way
>> as extern (C)?
>
> I wouldn't do it that way. I would use extern(C) with struct
> and function definitions/declarations, but I don't think it
> makes sense to use it with individual variables.
>
> Not sure if anything is wrong with export, but they are two
> different things. Export allows something to be visible to
> other programs(like in a shared library) and extern is(I
> believe) more so for specifying how something outside the
> program is meant to be linked in.
My program is a shared library, and it uses extern (C) to let
other programs access the extern (C)'d functions and such.
Could you give me a definition of export, as I believe I may have
the wrong meaning and use of it.
The reason being, is that I did some test with something like
this:
export int test(string[] args)
{
return 0;
}
and the program trying to find it couldn't, I suppose that's
where I went wrong?
Back the main topic, thank you, I wanted to use it for variables,
but if it's not safe I'll use getters and setters, or maybe ref
or something. The reason I wanted to is because I'm using it as a
sort of settings.
More information about the Digitalmars-d-learn
mailing list