Skip to content

Returning a constant from the ffi #59

@mikesol

Description

@mikesol

This isn't a bug but more of a question/potential point for documentation. I've been able to successfully implement functions in the FFI, but constants are proving a bit elusive for me. If I try to implement Global.infinity this way:

exports["infinity"] = []() -> boxed {
  return 1000.0;
};

And then I print it out later like this:

std::cout << "infinity " << unbox<double>(Global::infinity()) << std::endl;

I see the following output on the console:

infinity 6.90463e-310

I'm probably doing something wrong in the export, but I'm not quite sure how to get it to print the right number (in this case 1000.0, eventually I'll use the C++ infinity, but this is just a sanity check). Thanks in advance for your advice!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++Applies to the C++11 targetquestion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions