Skip to content
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

FontVariation conflict #86533

Closed
tamtakoe opened this issue Dec 26, 2023 · 6 comments
Closed

FontVariation conflict #86533

tamtakoe opened this issue Dec 26, 2023 · 6 comments

Comments

@tamtakoe
Copy link

tamtakoe commented Dec 26, 2023

Tested versions

4.2.stable

System information

MacOS 14.1.2 - Godot v4.2.stable

Issue description

If we are using Godot Control and WebKit together we get error

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/SFNTTypes.h:470:8: error: redefinition of 'FontVariation'
struct FontVariation {
       ^
./scene/resources/font.h:386:7: note: previous definition is here
class FontVariation : public Font {

Maybe we should provide some way to avoid this type of errors?

Steps to reproduce

Use WebKit with Godot Control.
We also can't wrap include <WebKit/WebKit.h> to a namespace because of

error: Objective-C declarations may only appear in global scope

Minimal reproduction project (MRP)

webkitdemo.zip

Put it in the modules folder and run

scons platform=macos arch=x86_64
scons platform=macos arch=arm64

See webkit_demo.mm file

#include "scene/gui/control.h"
#include <WebKit/WebKit.h>
@AThousandShips
Copy link
Member

This is an issue regarding a third party tool with no namespacing, I don't think we can cover every single third party thing not bundled with Godot, nor can we rename this or move it into a namespace, this is largely IMO a WebKit issue as it is a library, and should provide namespaces to prevent this exact kind of thing

@tamtakoe
Copy link
Author

@AThousandShips Do you know a workaround?

@AThousandShips
Copy link
Member

AThousandShips commented Dec 27, 2023

I don't know any, I don't know Objective-C, and my bad I had missed the part about namespacing there

This however is really not for this channel, I'd suggest asking in the other community channels

But Godot is an application and not a library, so namespaces aren't necessarily expected or useful, unfortunately this messes with the Objective-C implementation

So I'd suggest asking elsewhere as nothing here is necessarily an issue with the engine, nor could it be resolved without major reworks of the engine which isn't really feasible for this kind of issue

Thank you for your report and good luck with finding a solution, but closing this as there's nothing actionable here (as applying namespaces to Godot is out of the question, but you could open a proposal for it just to see)

Edit: you could also look into doing this as an extension via godot-cpp, which does use namespaces as it is a library in that sense

@AThousandShips AThousandShips closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
@bruvzg
Copy link
Member

bruvzg commented Dec 27, 2023

You can disable conflicting header.

#include "webkitdemo.h"

#define __APPLICATIONSERVICES__
#include <CoreGraphics/CoreGraphics.h>
#include <WebKit/WebKit.h>

In general, you can always make a wrapper class to avoid including both headers.

@tamtakoe
Copy link
Author

tamtakoe commented Dec 27, 2023

In general, you can always make a wrapper class to avoid including both headers.

Ohh... It means that we need to wrap every class of WebKit except FontVariation. Using godot-cpp looks easier. Do someone has a PoC of the WebKit inside GDextension? Especially how to use Objective-C code inside the extension?

@gilzoide
Copy link

A super hacky workaround that will probably work is redefining WebKit's FontVariation to another symbol (in this example "_FontVariation") by using a macro:

#define FontVariation _FontVariation
#include <WebKit/WebKit.h>
#undef FontVariation

After the redefinition, if you ever need to use it, refer to _FontVariation instead of FontVariation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants