Skip to content

Objective-C generated code results in module redefinition #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brianquinlan opened this issue Jul 9, 2024 · 2 comments · Fixed by #1339
Closed

Objective-C generated code results in module redefinition #1275

brianquinlan opened this issue Jul 9, 2024 · 2 comments · Fixed by #1339
Labels
lang-objective_c Related to Objective C support package:ffigen
Milestone

Comments

@brianquinlan
Copy link
Contributor

If I manually fix the issues in #1269, I get a compilation error:

Lexical or Preprocessor Issue (Xcode): Redefinition of module 'Foundation'
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Sy
stem/Library/Frameworks/Foundation.framework/Modules/module.modulemap:0:17

I think that is because the includes are not generated correctly:

#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSArray.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSData.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSDictionary.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURLCache.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURLRequest.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURLSession.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURL.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSProgress.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURLResponse.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSHTTPCookieStorage.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSOperation.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSError.h"
#include "../../../../../../../System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSDictionary.h"

Objective-C headers don't have header guards so I think that you need import rather than include.

Also, I'm not sure if the compiler will realize that #import "../../foo.h" and #import <foo.h> refer to the same file.

@brianquinlan brianquinlan added package:ffigen lang-objective_c Related to Objective C support labels Jul 9, 2024
@liamappelbe
Copy link
Contributor

Does it work if you switch them to import?

@brianquinlan
Copy link
Contributor Author

Does it work if you switch them to import?

No. But changing them to:

#import <Foundation/NSArray.h>

did work. As did removing them completely (because they are transitively included by "CUPHTTPClientDelegate.h").

I would also expect these relative paths to only work on my Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-objective_c Related to Objective C support package:ffigen
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants