API

Cxx.CxxCore.@cxxMacro
@cxx expr

Evaluate the given expression as C++ code, punning on Julia syntax to avoid needing to wrap the C++ code in a string, as in cxx"". The three basic features provided by @cxx are:

  • Static function calls: @cxx mynamespace::func(args...)
  • Member calls: @cxx m->foo(args...), where m is a CppPtr, CppRef, or CppValue
  • Value references: @cxx foo

Unary * inside a call, e.g. @cxx foo(*(a)), is treated as a dereference of a on the C++ side. Further, prefixing any value by & takes the address of the given value.

Note

In @cxx foo(*(a)), the parentheses around a are necessary since Julia syntax does not allow * in the unary operator position otherwise.

source
Cxx.CxxCore.@cxx_strMacro
cxx"C++ code"

Evaluate the given C++ code in the global scope. This can be used for declaring namespaces, classes, functions, global variables, etc. Unlike @cxx, cxx"" does not require punning on Julia syntax, which means, e.g., that unary * for pointers does not require parentheses.

source
Cxx.CxxCore.@icxx_strMacro
icxx"C++ code"

Evaluate the given C++ code at the function scope. This should be used for calling C++ functions and performing computations.

source
Cxx.CxxCore.cxxincludeFunction
cxxinclude([C::CxxInstance,] fname; isAngled=false)

Include the C++ file specified by fname. This should be used when the path of the included file needs to be assembled programmatically as a Julia string. In all other situations, it is avisable to just use cxx"#include ...", which makes the intent clear and has the same directory resolution logic as C++.

source
Cxx.CxxCore.addHeaderDirFunction
addHeaderDir([C::CxxInstance,] dirname; kind=C_User, isFramework=false)

Add a directory to the Clang #include path. The keyword argument kind specifies the kind of directory, and can be one of

  • C_User (like passing -I when compiling)
  • C_System (like -isystem)
  • C_ExternCSystem (like -isystem, but wrap in extern "C")

The isFramework argument is the equivalent of passing the -F option to Clang.

source