Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a cglobal intrinsic for C library global variables. #3073

Closed
stevengj opened this issue May 10, 2013 · 2 comments
Closed

a cglobal intrinsic for C library global variables. #3073

stevengj opened this issue May 10, 2013 · 2 comments

Comments

@stevengj
Copy link
Member

Currently, you can only access global variables by a combination of dlsym and dlopen: convert(Ptr{T}, dlsym(dlopen("libname"), "varname")). Not only is this ugly, but it will also make things difficult for future static compilation (where we would like to directly link any needed shared libraries with ld, rather than requiring them to be dlopened at runtime).

I'd like to suggest a cglobal(symbol, T=Void) intrinsic, returning a Ptr{T}, that mirrors ccall(symbol, ...). That is, the symbol argument could be a symbol, a (symbol,library) pair, or a pointer returned by dlsym (although in that case cglobal wouldn't do much, just a typecast).

(See #961 for some pre-history of this problem.)

@JeffBezanson
Copy link
Member

See also #1815

@stevengj
Copy link
Member Author

Ah, seems to be a duplicate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants