JuliaInterop / CxxWrap.jl

Package to make C++ libraries available in Julia
Other
418 stars 67 forks source link

Mirrored types (marked with IsMirroredType) can't be added using add_type #271

Closed NikEyX closed 3 years ago

NikEyX commented 3 years ago

Hi,

I keep on getting this error: Mirrored types (marked with IsMirroredType) can't be added using add_type, map them directly to a struct instead and use map_type or explicitly disable mirroring for this type, e.g. define template<> struct IsMirroredType<Foo> : std::false_type { };"); I don't really know what mirrored type means here to be honest, and I am also not able to fix the error. I could do map_type but then I have to define the struct in Julia and I would like it to be derived directly from the C++ code instead.

For example if I do

JLCXX_MODULE define_julia_module(jlcxx::Module& mod)
{
  mod.add_type<TestDate>("TestDate");
}

where TestDate is defined as:

struct TestDate {
  unsigned short    Year;       
  unsigned char Month;      
  unsigned char Day;        
};

then it will break and error about "mirrored type". So what does mirrored type mean here really and how can I make it work? (I am unsure where to put the define template part)

NikEyX commented 3 years ago

Still no idea why the mirrored type error comes up for a primitive type struct, but anyways, this is how you fix it if you want to force add_type: You have to dump it into the jlcxx namespace somewhere at the top of your cpp file

namespace jlcxx
{
  define template<> struct IsMirroredType<Foo> : std::false_type { };
}