Bug 17750 – DMD should consider namespaces when validating declaration names

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-08-12T23:39:02Z
Last change time
2024-12-13T18:54:03Z
Assigned to
No Owner
Creator
Roman Hargrave
Moved to GitHub: dmd#19301 →

Comments

Comment #0 by roman — 2017-08-12T23:39:02Z
In writing bindings for libtorch, a C++ machine learning framework, I ran in to a seemingly artificial limitation. I need to define external linkage for members of a class named Torch::Object. Unfortunately, the compiler will not let you declare a class named `Object` even if it is defined such that it would not collide with D's own Object the only "clean" way to do this (and only for non-virtual functions) is by manually specifying symbol names for each method with `pragma(mangle, ...)`. If fixing this by changing the validation logic actually presents issues, perhaps adding a pragma, like mangle, that tells the compiler what class name to use when generating C++ symbols would be a good solution.
Comment #1 by robert.schadek — 2024-12-13T18:54:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19301 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB