JuliaInterop / Cxx.jl

The Julia C++ Interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@cxx macro confusing parses

goretkin opened this issue · comments

julia> (@cxx fabs(2.0);)
2.0

julia> (@cxx fabs(2.0);) == 2.0
true

julia> @cxx fabs(2.0) == 2.0;
ERROR: UndefVarError: fabs not defined
Stacktrace:
 [1] top-level scope at REPL[10]:1

julia> @cxx (fabs(2.0) == 2.0;)
ERROR: LoadError: Unrecognized CPP Expression begin
    fabs(2.0) == 2.0
end (block)
Stacktrace:
 [1] error(::String, ::Expr, ::String, ::Symbol, ::String) at ./error.jl:42
 [2] cpps_impl(::Module, ::Expr, ::Expr, ::Bool, ::Bool, ::Bool) at /Users/goretkin/.julia/dev/Cxx/src/cxxmacro.jl:175
 [3] cpps_impl(::Module, ::Expr) at /Users/goretkin/.julia/dev/Cxx/src/cxxmacro.jl:136
 [4] @cxx(::LineNumberNode, ::Module, ::Any) at /Users/goretkin/.julia/dev/Cxx/src/cxxmacro.jl:200
in expression starting at REPL[11]:1

I'm not sure why the last one doesn't return "true", but I don't understand fully the different scopes in C++.