Bug 15098 – C++ namespace conflicts with D import

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-09-22T04:34:00Z
Last change time
2015-09-22T12:42:06Z
Keywords
C++
Assigned to
nobody
Creator
turkeyman

Comments

Comment #0 by turkeyman — 2015-09-22T04:34:03Z
Getting this error a lot: Error: namespace ud.kernel.kernel.ud conflicts with import ud.kernel.kernel.ud at udKernel\src\ud\kernel\kernel.d(3) This code: module ud.kernel.kernel; import ud.kernel.component; extern(C++, ud): class Kernel { ... } It seems the problem is that the root of the D namespace is 'ud', but my C++ namespace is also 'ud', and this doesn't seem to be acceptable. If I remove `ud.` from the D namespace, the errors stop. I think this is valid code, there are no guarantees that my C++ namespace is not the same as the root D namespace, infact it seems highly likely to me.
Comment #1 by Marco.Leise — 2015-09-22T04:46:00Z
I guess one can argue that there is no need to name the D package exactly after the C++ namespace. Maybe by convention a '_cpp' could always be appended or you could change the D package name to 'unlimited_detail', because two letter variable names are shunned upon anyways. Let's see what the compiler devs say why it is this way.
Comment #2 by dfj1esp02 — 2015-09-22T08:19:51Z
Looks like this compiles: --- module ud.kernel.kernel; extern(C++, ud): class Kernel { } --- Is the problem in the import?
Comment #3 by turkeyman — 2015-09-22T08:37:59Z
I guess the import introduces 'ud' in the local namespace, and the extern(C++) also introduces some 'ud' item into the local namespace... I'm not sure what kind of thing that 'ud' actually is. Marco: a long name at the root of the module hierarchy is really uncool, I would stick with 3 letters max. But I really would want it to be the same as the C++ if possible, since it's like, the same thing; a direct binding to the C++ code, so surely ALL the names should match, not just 'most' names.
Comment #4 by dfj1esp02 — 2015-09-22T10:04:15Z
The C++ binding depends on D code? Can C++ binding be moved it into a separate file so that it doesn't depend on D code and hence doesn't import D modules?
Comment #5 by dfj1esp02 — 2015-09-22T12:42:06Z
*** This issue has been marked as a duplicate of issue 13183 ***