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

Comments

@Geod24
Copy link
Member

@Geod24 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 self-assigned this Feb 19, 2020
@AndrejMitrovic

This comment has been minimized.

Copy link
Member

@AndrejMitrovic AndrejMitrovic commented Feb 19, 2020

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

This comment has been minimized.

Copy link
Member Author

@Geod24 Geod24 commented Feb 19, 2020

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

@Geod24

This comment has been minimized.

Copy link
Member Author

@Geod24 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 this to To do in Sprint #12 (2020-02-25 to 2020-03-9) via automation Feb 25, 2020
@Geod24 Geod24 moved this from To do to In progress (Max 5) in Sprint #12 (2020-02-25 to 2020-03-9) Mar 1, 2020
@bpalaggi bpalaggi added this to To do in Sprint #13 (2020-03-10 to 2020-03-23) via automation Mar 10, 2020
@bpalaggi bpalaggi removed this from In progress (Max 5) in Sprint #12 (2020-02-25 to 2020-03-9) Mar 10, 2020
@bpalaggi bpalaggi moved this from To do to In progress (Max 5) in Sprint #13 (2020-03-10 to 2020-03-23) Mar 10, 2020
@bpalaggi bpalaggi removed this from In progress (Max 5) in Sprint #13 (2020-03-10 to 2020-03-23) Mar 24, 2020
@bpalaggi bpalaggi added this to To do in Sprint #14 (2020-03-24 to 2020-04-6) via automation Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.