Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importcpp + CRTP: Compiler exit without output or errors #16655

Open
mratsim opened this issue Jan 9, 2021 · 0 comments
Open

importcpp + CRTP: Compiler exit without output or errors #16655

mratsim opened this issue Jan 9, 2021 · 0 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Jan 9, 2021

Nim supports CRTP (Curiously recurring template pattern) in its type system:

type
  Example*{.bycopy.}[Data, Target] = object
    data*: Data
    target*: Target

  BatchDataset*{.bycopy, pure, inheritable.} = object

  Dataset*{.bycopy, pure.}[Self, Batch] = object of BatchDataset

  Mnist*{.bycopy, pure.} = object of Dataset[Mnist, seq[Example[float64, float64]]]

func mnist(rootPath: cstring): Mnist =
  discard

let m = mnist("path/to/mnist")
echo "Success"
echo m

but when this is used for C++ bindings, the compiler exits without producing code or errors, there is not even a nimcache folder created.

type
  Example*{.bycopy, importcpp: "torch::data::Example".}[Data, Target] = object
    data*: Data
    target*: Target

  BatchDataset*{.bycopy, pure, inheritable,
    importcpp: "torch::data::datasets::BatchDataset".}
    = object

  Dataset*{.bycopy, pure,
    importcpp: "torch::data::datasets::Dataset".}[Self, Batch]
    = object of BatchDataset

  Mnist*{.bycopy, pure,
    importcpp: "torch::data::datasets::MNIST".}
    = object of Dataset[Mnist, seq[Example[float64, float64]]]

func mnist(rootPath: cstring): Mnist =
  discard

let m = mnist("path/to/mnist")
echo "Success"
echo m

Note: obviously the C++ compiler will refuse to compile since you don't have the header and DLL, but it shouldn't exit silently at the Nim level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant