Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Workaround Issue 17081 - Bodies in extern cpp functions in D files are not linked#1736

Merged
andralex merged 1 commit intodlang:masterfrom
Darredevil:issue-17081
Jan 14, 2017
Merged

Workaround Issue 17081 - Bodies in extern cpp functions in D files are not linked#1736
andralex merged 1 commit intodlang:masterfrom
Darredevil:issue-17081

Conversation

@Darredevil
Copy link
Contributor

@kinke
Copy link
Contributor

kinke commented Jan 13, 2017

Why do you implement these functions? Isn't adding the const qualifier to name() enough to fix the linking error? As a side note, you don't check whether _arg for before() is null, but claim that the function is nothrow...

@Darredevil
Copy link
Contributor Author

@kinke adding const was not enough to fix the problem, see the bug tracker link for example. Implementing them was the only way to fix the problem.
As for not checking for null, it's because I translated the exact source code from the GNU stdcpp, however you are correct, the nothrow will be removed.

@dnadlinger
Copy link
Contributor

From the bug tracker:

I propose actually implementing all non-virtual functions from druntime/src/core/stdcpp in order to solve this.

Before rushing in a fix, it is important to figure out what is going wrong here. Linking against non-virtual C++ function is supposed to work (unless, of course, they are static/inline on the C++ side). Comparing the mangled name would be a first step.

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before rushing in a fix, it is important to figure out what is going wrong here.

This is a fine workaround. We'll end up implementing a few functions on the C++ side for inlining purposes anyway.

return _name[0] == '*' ? _name + 1 : _name;
}
final bool before()(const type_info _arg) const {
import core.stdc.string:strcmp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces around :, cc @wilzbach

import core.stdc.string:strcmp;
return (_name[0] == '*' && _arg._name[0] == '*')
? _name < _arg._name
: strcmp (_name, _arg._name) < 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space before ( in function call (i.e. use math-like notation), cc @wilzbach

@andralex
Copy link
Member

BTW this shall not be considered a fix, so I'll change the title.

@andralex andralex changed the title Fix Issue 17081 - Bodies in extern cpp functions in D files are not linked Workaround Issue 17081 - Bodies in extern cpp functions in D files are not linked Jan 14, 2017
@Darredevil
Copy link
Contributor Author

@andralex Fixed spacing, waiting final tests for merge

@andralex
Copy link
Member

Auto-merge toggled on

@andralex
Copy link
Member

@Darredevil great, thx. Next step would be probably to actually see the problem with https://issues.dlang.org/show_bug.cgi?id=17081.

Also please push this again, looks like the autotester failed for no cause. cc @MartinNowak @braddr

@kinke
Copy link
Contributor

kinke commented Jan 14, 2017

@andralex: Related & trivial, but sitting there for more than a month already and mentioning more C++ interop issues: #1709

@andralex andralex merged commit e3e8b23 into dlang:master Jan 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants