Comments (9)
Apologies for the slow response. I'm kind of puzzled because those structs starting with two underscores should be skipped. Can you add the following so we can figure out what definition this is choking on?
@@ -422,6 +424,7 @@ function wrap_header(wc::WrapContext, topcu::CLCursor, top_hdr, ostrm::IO)
else
continue
end
+ println(name(cursor))
end
cindex.cl_dispose(topcl)
from clang.jl.
I'm getting a similar error. I inserted the println
, here's the gist: https://gist.github.com/timholy/8468205.
from clang.jl.
The underlying problem was poor documentation, but the immediate cause was that header_library
only worked properly with a Function. I added a little bit of help so that a function is generated automatically when an ASCIIString is provided. With this and 9c055bb (for a limitation exposed by yaml.h), both of these are now generated cleanly for me.
from clang.jl.
@timholy I used these commands (adding common_file
keyword in init):
using Clang
context=wrap_c.init(;output_file="libcudart.jl", common_file="libcudart_h.jl", header_library=x->"libcudart", clang_includes=["/usr/include"], header_wrapped=(x,y)->contains(x,"cuda"))
wrap_c.wrap_c_headers(context, [joinpath("/usr/include","cuda_runtime_api.h")])
from clang.jl.
btw, you are probably aware of this - but just in case: https://github.com/lindahua/CUDA.jl/
from clang.jl.
Thanks, Isaiah!
I am aware of Dahua's work, which is really nice. But, I am trying to port an application written in C++ against CUDA-5.0 (Dahua's is 3.2, I think), and after trying to make many conversions I began to wonder if it would just be easier to wrap 5.0.
Sorry to keep troubling you, but one of the things that's missing from the output are some of the complex types, like cudaDeviceProp
. Here's my current wrapper-generator:
using Clang
context=wrap_c.init(;output_file="libcudart.jl", common_file="libcudart_h.jl", header_library=x->"libcudart", clang_includes=["/usr/include"], header_wrapped=(x,y)->contains(x,"cuda")||contains(x,"driver"))
path = "/usr/local/cuda-5.0/include"
headers = [joinpath(path, "driver_types.h"), joinpath(path,"cuda_runtime_api.h")]
wrap_c.wrap_c_headers(context, headers)
I verified that clang can indeed parse that file, following your very helpful notebook but with
top = cindex.parse_header("driver_types.h", includes=["/usr/include","/usr/lib/gcc/x86_64-redhat-linux/4.4.4/include"])
For cudaDeviceProp
I was able to get all the way through Example 1 without error and with printed output looking promising. So it suggest this is well within Clang's capabilities (which is quite impressive). But I can't find the immutable definition anywhere in the generated files. I also couldn't find any of the much simpler structs, like cudaExtent
, so it suggests to me that I'm doing something wrong.
from clang.jl.
Never mind! I figured this part out by reading through the sources and adding
context.options = wrap_c.InternalOptions(true) # wrap structs, too
from clang.jl.
Sorry about that, I will add it as a keyword to the init
function so it is more discoverable. You can also do
context.options.wrap_c_structs = true
from clang.jl.
Also, as a word of warning: some of the preprocessor constants will probably require manual editing if they end with "L" or "U". The libclang preprocessor interface is basically "here is the string", and right now wrap_c
only does a rudimentary tokenization to exclude unsupportable macro definitions. Unfortunately it does not check the constants yet.
As you may notice, I got rid of the macros, so full functions are printed containing ccalls (in order to be more editable). In some cases it might be useful to disable printing of argument types in the function signature in order to duck-type, because Julia does not do the same kind of auto-promotion for a function as for the special ccall form:
@@ -268,7 +268,8 @@ function wrap(buf::IO, funcdecl::FunctionDecl, libname::ASCIIString)
function print_args(buf::IO, cursors, types)
i = 1
for (c,t) in zip(cursors,types)
- print(buf, name(c), "::", t)
+ #print(buf, name(c), "::", t)
+ print(buf, name(c))
(i < length(cursors)) && print(buf, ", ")
i += 1
end
from clang.jl.
Related Issues (20)
- Error when parsing alignas(64) HOT 3
- Various non-valid Julia code output HOT 8
- MIOpen generator fails HOT 4
- Support `_Atomic` HOT 2
- Support variable array function parameters
- C_LONG_LONG and C_INT64_T represented as Clong HOT 4
- `__restrict not defined` Error HOT 3
- Edge cases encountered while generating bindings for Hwloc HOT 1
- Enumerations with a fixed underlying type, via typedef HOT 1
- Bug introduced in Clang.jl v0.16.6 HOT 10
- Definitions of function pointer types should appear before their first use HOT 4
- Creating bindings for libwinit HOT 11
- size_t wrongly translated to Cint HOT 2
- Feature Request: implement `smart_deanonymize` for cenums HOT 1
- Using `fieldnames` (and similar) for wrapped C `union`s HOT 2
- Unexpected assertion error: ERROR: AssertionError: length(child_nodes) == length(fields) HOT 1
- Support for `using` HOT 3
- generating julia wrapper for C library
- Unknown CXCursorKind with Julia master/Clang.jl master HOT 2
- Unhandle type c"CXType_Int128": __int128 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clang.jl.