Hi Jan,

first of, I recommend using the string macros icxx and cxx over the @cxx
syntax. That should make it a lot clearer what's happening. To answer your
question,

@cxx reader, is the equivalent of icxx"reader;",
however @cxx reader->stuff is the equivalent of icxx"$reader->stuff", so
reader is searched for in julia scope rather than C++ scope. Hope that
makes sense.

Keno

On Wed, May 25, 2016 at 7:54 PM, Jan Strube <jan.str...@gmail.com> wrote:

> I've created a rudimentary set of bindings to the LCIO file format
> <http://lcio.desy.de/v02-07/doc/>.
> It's an event data model and file format for detector and physics studies
> of future linear collider concepts.
> The code is over on github https://github.com/jstrube/LCIO.jl
> The purpose of this post isn't to announce this code, however, since at
> the moment it's rather fugly and jumping through extern "C" {} stubs.
>
> I would like to improve the usability a little and thought that Cxx.jl
> could help with that, but I'm struggling with the first steps.
> I have Cxx installed, but I'm confused about how to use it.
> I'm using the following to set it up.
>
> using Cxx
> addHeaderDir(joinpath(ENV["LCIO"], "include"), kind=C_User)
> Libdl.dlopen(joinpath(ENV["LCIO"], "lib", "liblcio.so.2.7.1"),
> Libdl.RTLD_GLOBAL)
> cxxinclude("lcio.h")
> cxxinclude("IO/LCReader.h")
> cxxinclude("IOIMPL/LCFactory.h")
> cxx"IO::LCReader* reader =
> IOIMPL::LCFactory::getInstance()->createLCReader();"
>
> This works fine.
> However, I would prefer this as the last line instead:
> reader = @cxx IOIMPL::LCFactory::getInstance()->createLCReader()
>
> Unfortunately, this gives me "IOIMPL not defined."
> Similarly,
> julia> @cxx reader
> (class IO::LCReader *) @0x0000000002fb0b70
>
> julia> @cxx reader->open(pointer("gev250ee_higgs_ZZ_001_tracking.slcio"))
> ERROR: UndefVarError: reader not defined
>  in eval(::Module, ::Any) at ./boot.jl:225
>  in macro expansion at ./REPL.jl:92 [inlined]
>  in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
>
> So "reader" is found and has the right type, but when trying to access
> member functions, it's no longer found???
> I'd file a bug report, but I'm not at all sure I'm actually using this
> correctly.
>
> If you can think of a reason why this behavior is expected, and what I
> could do to remedy, please let me know.
>
>

Reply via email to