Ebiten: "unexpected '@' in program" running examples on macOS

Created on 11 Jan 2019  路  23Comments  路  Source: hajimehoshi/ebiten

On macOS 10.11.6 (El Capitan), with the latest ebiten from the master branch:

~/go/src/github.com/hajimehoshi/ebiten/examples/sprites [master|鉁擼
14:18 $ go run main.go
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
ca.m:49:7: error: unexpected '@' in program
ca.m:54:13: warning: instance method '-setMaximumDrawableCount:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
ca.m:65:7: error: unexpected '@' in program
ca.m:68:37: warning: instance method '-setDisplaySyncEnabled:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here

Not sure if this is a bug with ebiten, or if I'm just on too old a version of macOS now you're using Metal for rendering.

Works fine with latest release (v1.8.1).

bug macos

All 23 comments

Hi, thank you for reporting!

Which version of Xcode are you using? Probably my current Metal code, which v1.8.1 doesn't use, uses @ syntax.

I don't think I actually even have Xcode installed.

OK so probably you are using a pre-installed gcc, which might be old. What would /usr/bin/xcodebuild -version say?

You can install Xcode by xcode-select --install but this might take some long time.

https://www.ics.uci.edu/~pattis/common/handouts/macclion/clang.html

$ /usr/bin/xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

馃

Could be an old gcc. I don't think I've ever needed it in the 3 or so years I've had this machine, so I'd never have updated it myself.

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Hmm, ok.

The cause is the usages of @available syntax.

https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/marking_api_availability_in_objective-c

I'm thinking to avoid this by macro. Please stay tuned (it's also ok if you want to update macOS or Xcode now).

Cool. 馃憤

It's no big deal for me at the moment anyway. This is my work laptop (hence the old macOS that I can't update 馃槩), and it does work fine on my personal laptop, which has the latest macOS.

For my purposes, locking this laptop's version of ebiten to v1.8.1 works for now.

$ /usr/bin/xcodebuild -version

What about xcodebuild -version? Thanks!

$ /usr/bin/xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Guess I must have installed them independently of xcode

I mean, what plain xcodebuild -version would say, instead of /usr/bin/xcodebuild -version.

It's the same. The /usr/bin/xcodebuild is the first one in my PATH.

$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

$ which xcodebuild
/usr/bin/xcodebuild

OK thanks!

Hmm, there seems no good macro to detect whether @available syntax is available or not. Probably I'd need to remove this...

Could you update your Ebiten and try it again? Thanks!

~/go/src/github.com/hajimehoshi/ebiten/examples/sprites [master|鉁擼
15:36 $ git pull
Updating 802f3cfe..72c1a73c
Fast-forward
 internal/graphicsdriver/metal/ca/ca.go |  5 ++++-
 internal/graphicsdriver/metal/ca/ca.m  | 36 ++++++++++++++++++++++--------------
 2 files changed, 26 insertions(+), 15 deletions(-)

~/go/src/github.com/hajimehoshi/ebiten/examples/sprites [master|鉁擼
15:36 $ go run main.go
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
ca.m:59:11: warning: instance method '-setMaximumDrawableCount:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
ca.m:77:35: warning: instance method '-setDisplaySyncEnabled:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten
../../run.go:25:9: undefined: __EBITEN_REQUIRES_GO_VERSION_1_11_OR_LATER__

__EBITEN_REQUIRES_GO_VERSION_1_11_OR_LATER__

This means that you should use Go 1.11 or later :-)

Huh. Thought I just updated that. Let me actually update properly and try again.

~/go/src/github.com/hajimehoshi/ebiten/examples/sprites [master|鉁擼
15:57 $ go version
go version go1.11.4 darwin/amd64

~/go/src/github.com/hajimehoshi/ebiten/examples/sprites [master|鉁擼
15:57 $ go run main.go
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
ca.m:59:11: warning: instance method '-setMaximumDrawableCount:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
ca.m:77:35: warning: instance method '-setDisplaySyncEnabled:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]

screen shot 2019-01-11 at 15 59 29

Hmmm, that's unfortunate, I have no idea what is going on.

Another idea is to force to use OpenGL instead of Metal in such old macOS environment. Let me think... 馃

That sounds like a reasonable compromise; you can't support older versions of macOS forever.

Potentially it could be made to work with Metal in old macOS in future, but your time is probably better spent with other features. :)

Forcing OpenGL works. Tested by hacking https://github.com/hajimehoshi/ebiten/blob/master/internal/graphicscommand/driver_mac.go to

package graphicscommand

import (
    "github.com/hajimehoshi/ebiten/internal/graphicsdriver"
    "github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
)

func Driver() graphicsdriver.GraphicsDriver {
    return opengl.Get()
}

From the discussion in gophers slack, it sounds like we could get away with doing this for macOS versions before 10.12 (which it sounds like this works fine).

At the moment, simply importing the metal packages results in those warnings, so it may need some awkward code to get this to work nicely 馃

Thank you for confirming!

Fixed to use OpenGL when macOS is 10.11 or older. (We have already confirmed that Metal worked on macOS 10.12 or newer).

Yep. Confirmed that this does work :)

screen shot 2019-01-11 at 16 33 42

We do still get the warnings as before, but thats less important than the main thing, which is that it works 馃帀

~/go/src/github.com/hajimehoshi/ebiten/examples/life [master|鉁擼
16:32 $ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 5 (delta 4), reused 5 (delta 4), pack-reused 0
Unpacking objects: 100% (5/5), done.
From https://github.com/hajimehoshi/ebiten
   72c1a73c..dc0c6e09  master     -> origin/master
Updating 72c1a73c..dc0c6e09
Fast-forward
 internal/graphicscommand/driver_mac.go | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

~/go/src/github.com/hajimehoshi/ebiten/examples/life [master|鉁擼
16:32 $ go run main.go
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]
ca.m:59:11: warning: instance method '-setMaximumDrawableCount:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
ca.m:77:35: warning: instance method '-setDisplaySyncEnabled:' not found (return type defaults to 'id') [-Wobjc-method-access]
/System/Library/Frameworks/QuartzCore.framework/Headers/CAMetalLayer.h:44:12: note: receiver is instance of class declared here
# github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca
warning: unknown warning option '-Wno-unguarded-availability-new'; did you mean '-Wno-partial-availability'? [-Wunknown-warning-option]

Yeees! It would be impossible to remove all the warning, but I think that's acceptable.

Thank you for cooperation!

Yep. It's a build warning anyway, so a compiled app throws no errors.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hajimehoshi picture hajimehoshi  路  6Comments

hajimehoshi picture hajimehoshi  路  4Comments

hajimehoshi picture hajimehoshi  路  7Comments

silbinarywolf picture silbinarywolf  路  4Comments

cretz picture cretz  路  4Comments