Getting preprocessor directives from a C library


I’m trying to use a C library in Julia. As part of it, I need/would like to access some variables / “functions” that are defined like so:

#define FOO 1
#define BAR(a,b)  (int)(a+b)

cglobal and ccall give me errors like “could not load symbol” and and “could not find function”. They work for ‘actual’ functions in the library.

Is it just not possible to access these values?

Sorry if it’s a silly question - I really don’t know what I’m doing when it comes to C.


Correct. They are only availabe in the header so you need something that look at the header for that.
Cxx.jl should handle that. Other C compiler/clang based solution might too. (CxxWrap.jl and to a less degree Clang.jl)

1 Like

Thanks, that lead me to which does what I want.

1 Like