fix: modern clang compatibility (c++03, fgets, tolower, macOS ld) - #32
Closed
bqw371 wants to merge 1 commit into
Closed
fix: modern clang compatibility (c++03, fgets, tolower, macOS ld)#32bqw371 wants to merge 1 commit into
bqw371 wants to merge 1 commit into
Conversation
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.
Summary
Three fixes required to build
libretro-fceuxwith modern clang (Apple clang 15+ / LLVM 16+) on macOS arm64 or cross-compiling for arm64-Linux. All three are straightforward correctness fixes that silence hard errors (not just warnings).1.
src-fceux/cheat.cpp—fgets()pointer vs int comparisonfgets()returnschar*, so comparing with>0is a pointer-to-integer comparison, which is an error in modern clang (-Werroror by default in strict mode).2.
src-fceux/utils/xstring.cpp— conflictingtolowerdeclarationThe file declares its own
extern "C" int tolower(int)which conflicts with<cctype>'stolower. Modern clang rejects conflicting linkage specifications.3.
Makefile.libretro-fceux— C++03 mode + macOS linker flag-std=c++03 -Wno-narrowing -Wno-reserved-user-defined-literaltoCXXFLAGS: required because the source uses C++03 idioms that are errors under C++11+ defaults in modern clang.-Wl,-no-undefinedinsideifneq ($(platform), osx): Apple ld does not support this flag.Tested on
platform=osx→libretro.dylib(494 KB)platform=unix→libretro.so(~500 KB)Note on
libretro-fceux/libretro.cpThe Makefile uses
$(wildcard *.cpp)to collect source files, but the libretro shim is namedlibretro.cp(missing finalp). A copy namedlibretro.cppis needed alongside it. Not included in this patch as the right fix may be to update the Makefile glob to also match*.cp.