fix(build): guard CG type redefinitions against libs-base CFCGTypes.h#15
Open
DTW-Thalion wants to merge 1 commit into
Open
fix(build): guard CG type redefinitions against libs-base CFCGTypes.h#15DTW-Thalion wants to merge 1 commit into
DTW-Thalion wants to merge 1 commit into
Conversation
libs-base's Headers/CoreFoundation/CFCGTypes.h (pulled in transitively via Foundation/NSGeometry.h) already declares CGPoint, CGSize, CGRect, the CGRectMinXEdge..CGRectMaxYEdge anonymous enum, and struct CGAffineTransform. Redefining them a second time in libs-opal's CGGeometry.h / CGAffineTransform.h is a hard error on clang 18 and gcc-objc. Detect libs-base's CFCGTypes.h via its own include guard (_CFCGTypes_h_GNUSTEP_BASE_INCLUDE) and skip the duplicates. CGRectEdge itself is NOT provided by CFCGTypes.h, so that typedef is always emitted. The NSRect/NSPoint/NSSize conversion helpers (NSRectToCGRect etc.) are also provided by NSGeometry.h when CFCGTypes.h is present, so they are skipped in the same block. No functional change on Windows / MSYS2 where CFCGTypes.h is not in the include path — those builds see the existing definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
I believe this is fixed now with #16 @DTW-Thalion can you let me know if I missed anything? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building libs-opal on Linux against a modern libs-base install fails with:
Root cause:
libs-base/Headers/CoreFoundation/CFCGTypes.h(transitively included via<Foundation/NSGeometry.h>) already declaresCGPoint,CGSize,CGRect, theCGRectMinXEdge..CGRectMaxYEdgeanonymous enum, andstruct CGAffineTransform. libs-opal's own headers then redeclare the same types unconditionally, which is a hard error under clang and gcc.The
NSRect/NSPoint/NSSize↔ CG conversion helpers (NSRectToCGRect,NSRectFromCGRect,NSPointToCGPoint,NSPointFromCGPoint,NSSizeToCGSize,NSSizeFromCGSize) are also provided byNSGeometry.hwhen CFCGTypes.h is present, and collide for the same reason.Fix
Detect libs-base's CFCGTypes.h via its own include guard
_CFCGTypes_h_GNUSTEP_BASE_INCLUDEand skip the duplicate declarations inCGGeometry.handCGAffineTransform.h.CGRectEdgeitself is not provided by CFCGTypes.h (only the enum values are), so thetypedef int CGRectEdge;is always emitted — otherwise CGGeometry.h line 140 would reference an undeclared type.Environment
/usr/localmake CC=clang CXX=clang++Platform impact
__APPLE__path defines its own CG types and doesn't include CFCGTypes.h.Test plan
_CFCGTypes_h_GNUSTEP_BASE_INCLUDEwhich isn't defined under Apple's CoreGraphics)