Closed bjarthur closed 3 years ago
julia> wc = init(common_file="common.jl", headers=["NIDAQmx.h"])
I don't think this is the recommended way to use the init
function. If there is no limitation on which header should be wrapped, Clang will try to wrap every header that indirectly used in the target header(e.g. libc), so this can be fixed by adding header_wrapped = (root, current)->root == current
.
using Clang
NIDAQmx_H = joinpath(@__DIR__, "NIDAQmx.h")
wc = init(; headers = [NIDAQmx_H],
output_file = "NIDAQmx.jl",
common_file = "common.jl",
clang_includes = vcat(CLANG_INCLUDE),
clang_args = map(x->"-I"*x, find_std_headers()),
header_wrapped = (root, current)->root == current,
header_library = x->"nidaqmx",
clang_diagnostics = true)
run(wc)
thanks! that runs without errors.
however, there is now a typedef which is not getting translated to julia properly. specifically:
typedef struct CVITime { uInt64 lsb; int64 msb; } CVITime;
typedef union CVIAbsoluteTime { CVITime cviTime; uInt32 u32Data[4]; } CVIAbsoluteTime;
comes out as:
struct CVIAbsoluteTime
cviTime::CVITime
end
simple to fix by adding struct CVITime; lsb::uInt64; msb::int64; end
, but shouldn't Clang have done this automatically?
Looks like it hit a corner case when wrapping that typedef struct(the code defines a struct firstly and then typedef a type with the same name...).
I'm still looking for a good way to overhaul the struct/union wrapping logic. Unfortunately, I don't have enough bandwidth to start for now. As a result, it's highly recommended to manually check the generated code for non-trivial unions as it might contain alignment bugs. You might also be interested in https://github.com/JuliaInterop/Clang.jl/issues/233#issuecomment-523260973 on how to manually map C unions in Julia.
oh, wait! Is this the same issue as https://github.com/JuliaInterop/Clang.jl/issues/249 which was fixed a while ago by https://github.com/JuliaInterop/Clang.jl/pull/250?
@bjarthur, it looks like @wsphillips is also working on this wrapper: https://github.com/wsphillips/NIDAQ.jl.
I think this has already been fixed by #250.
i get the same error as https://github.com/JuliaInterop/Clang.jl/issues/234, but the solution there does not seem to apply here.
NIDAQmx.h
is herethis is with julia 1.3.1 and the clang 0.9.1.
any suggestions as to how i can fix this? thanks.