stephan-tolksdorf / STULabel

A faster and more flexible label view for iOS
Other
121 stars 28 forks source link

OSTypes.h UInt Collision #5

Closed b3ll closed 4 years ago

b3ll commented 5 years ago

When compiling for Catalyst (iOSMac) it seems to import OSTypes.h (which also imports MacTypes.h) and OSTypes.h defines UInt which collides with the one used in Config.hpp.

I'm not sure what the easy fix for this is, we could codemod everything to use the stu:: prefix, but that'd make things look super verbose. I don't know enough C++ to do anything otherwise tho :/

stephan-tolksdorf commented 5 years ago

I've filed a bug with the feedback assistant for this issue: FB6149720. Maybe you want to dupe it. See also this twitter thread: https://twitter.com/s_tolksdorf/status/1138831776355368960

I'll see whether I can (temporarily?) work around this problem without mutilating the code.

Feedback assistant category: Developer Tools

Please provide a descriptive title for your feedback: When compiling for iosMac importing CoreGraphics pulls in global UInt typedef from libkern/OSTypes.h

Which area are you seeing an issue with? ‌Something else not on this list

What type of feedback are you reporting? Incorrect/Unexpected Behavior

Description When building for iosMac in Xcode 11 on macOS Catalina, importing CoreGraphics imports IOKit, which imports the libkern module and its OSTypes.h header, which defines UInt as a global 32-bit integer typedef. Due to the extremely common name of this global typedef and the definition as an unsigned int as opposed to an unsigned long this will cause compilation errors in a lot of code bases that define a conflicting UInt type. This issue doesn’t occur when building e.g. for iOS.

Please list the steps you took to reproduce the issue: 1) Create a new “Single View App” Objective-C App project in Xcode 11 on macOS 10.15. 2) Select a Team in the Signing & Capabilities -> Signing settings of the target. 3) Enable “Mac” in the “Deployment Info” settings of the target. 4) Select “My Mac” as the device. 4) Add the line typedef unsigned long UInt; under the line #import “ViewController.h” in ViewController.m. 5) Build the target.

What did you expect to happen? The target should build successfully (independent of whether “My Mac” or an iOS simulator is selected as the device).

What actually happened? The compilation fails with the following error: error: typedef redefinition with different types ('unsigned long' vs 'unsigned int') typedef unsigned long UInt; ^ In module 'UIKit' imported from /Users/stephan/test2/test2/ViewController.h:9: In module 'CoreGraphics' imported from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:10: In module 'IOKit' imported from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayConfiguration.h:12: In module 'libkern' imported from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/IOKit.framework/Headers/IODataQueueClient.h:31: /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/libkern/OSTypes.h:36:28: note: previous definition is here typedef unsigned int UInt; ^ 1 error generated.

When selecting an iOS simulator as the device, the target builds fine.

b3ll commented 5 years ago

oh no worries at all, if it's a bug I'll happily wait for the seed that fixes it :P

Besides, if I /really/ needed it to work I could just change OSTypes temporarily