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

[C++] Document usage of C++ types, limitations, and patterns #560

Open
Geod24 opened this issue Feb 19, 2020 · 3 comments
Open

[C++] Document usage of C++ types, limitations, and patterns #560

Geod24 opened this issue Feb 19, 2020 · 3 comments
Assignees
Labels
C.General An issue which doesn't fit in the other categories (not blockchain related) type-enhancement An improvement of existing functionalities
Milestone

Comments

@Geod24
Copy link
Collaborator

Geod24 commented Feb 19, 2020

Currently we don't have a good documentation about what can, should, and shouldn't be done with extern(C++) types. Given there are a lot of technicalities involved, it would be good to have a rather extensive documentation.

Such a documentation would introduce knowledge of constructs in D that are safe to use, as well as C++-specific knowledge, for example copy constructors, default constructors, constructors deletion, move constructors, non-representable types, etc...

That documentation is also very likely to be specific to the version of C++ we're using (there are some subtle differences between C++11, C++14 and C++17, and we're currently using the later).

Another note: The D documentation for C++ interfacing is wildly outdated...

@Geod24 Geod24 added the type-enhancement An improvement of existing functionalities label Feb 19, 2020
@Geod24 Geod24 self-assigned this Feb 19, 2020
@AndrejMitrovic
Copy link
Contributor

Hmm yeah. Looking at it now again, we return vectors to the C++ side - for example in combineCandidates. But when we return it by value we don't do a deep copy (to the C heap), the vectors still contain references to GC allocated memory (which then goes out of scope).

@Geod24
Copy link
Collaborator Author

Geod24 commented Feb 19, 2020

Return by value is actually fine, it uses NRVO so dtor / copy ctors are not involved

@Geod24
Copy link
Collaborator Author

Geod24 commented Feb 19, 2020

Re unwanted moves, on the C++ side we have https://reviews.llvm.org/D43322 (flag -Wreturn-std-move).

@Geod24 Geod24 added this to the 2. Validator milestone Feb 25, 2020
@Geod24 Geod24 added the C.General An issue which doesn't fit in the other categories (not blockchain related) label Jul 5, 2020
@Geod24 Geod24 modified the milestones: 6. Stabilization, 99. Unbounded Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C.General An issue which doesn't fit in the other categories (not blockchain related) type-enhancement An improvement of existing functionalities
Projects
None yet
Development

No branches or pull requests

4 participants
@Geod24 @AndrejMitrovic @bpalaggi and others