- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 414
config.d: use enums instead of structs for __c_long, etc. #2160
Conversation
| Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2160" | 
089e1c9    to
    693784a      
    Compare
  
    | * Both of these break existing code, so until we find a resolution the types are named | ||
| * cpp_xxxx. | ||
| */ | ||
| enum __c_long : int; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had no clue that it was even legal to declare an enum with no members. That seems very weird. Is the point of doing this instead of using an alias so that it's a distinct type from int? I guess that that would mean that this technique is a typedef of sorts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the point of doing this instead of using an alias so that it's a distinct type from int?
Yes, so that the compiler can do special mangling for that type. Although I don't see how it's any better than a struct. I proposed to add support for adding pragma(mangle) to alias declarations but Walter doesn't seem to like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you go down that path, you'll discover you've reinvented enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmdavis BTW, one use case of declaring an enum without any members is to use it as a UDA that doesn't contain any data.
| This is a Vision issue, as it resolves a long-running sore in compatibility with C++. | 
|  | ||
| version (Darwin) | ||
| { | ||
| alias cpp_size_t = cpp_ulong; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we do the other way around, i.e. alias size_t = cpp_ulong in object.d? This would be to avoid having to use cpp_size_t instead of size_t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to do that separately.
| I think there should be a test somewhere (in druntime or in DMD) that verifies that the correct mangling is used. | 
| 
 | 
| @CyberShadow I don't understand this error message:  | 
| DAutoTest appears to fail the same way with other PRs, so is not caused by this PR. | 
| The problem is in DMD's handling of programs from stdin: | 
| @CyberShadow thanks for the quick fix on that! | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move on with this then.
needs dlang/dmd#8152