Closed1

【Mac】g++ で SDL2 をコンパイルすると 'error: missing binary operator before token "("'

開発メモ開発メモ

エラー内容

SDL2 は brew でインストール済み。
SDL2 を含んでコンパイルすると以下のエラーが発生。g++ を使用。

In file included from /opt/homebrew/include/SDL2/SDL_platform.h:76,
                 from /opt/homebrew/include/SDL2/SDL_config.h:33,
                 from /opt/homebrew/include/SDL2/SDL_stdinc.h:31,
                 from /opt/homebrew/include/SDL2/SDL_main.h:25,
                 from /opt/homebrew/include/SDL2/SDL.h:32,
                 from Sample.h:2,
                 from Sample.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/TargetConditionals.h:140:50: error: missing binary operator before token "("
  140 | #if !defined(__has_extension) || !__has_extension(define_target_os_macros)

もともと clang を使っていたが、以下のスクラップ経緯で、clang から g++ を使うように変更。調べてみても解決策が特に見つからない。今のところ clang でしか使えないような記事をいくつか見つけたので、諦めて clang を使う。
https://zenn.dev/shida_dev/scraps/fc42f039570c8d

このスクラップは1ヶ月前にクローズされました