[BUILD][UNIX] Failure on macOS w/ Xcode 16.4, `error: unknown type name 'Fixed'`
Summary
Compilation failure on macOS 15 / Xcode 16.4 with message: error: unknown type name 'Fixed'.
POV-Ray Version
- Incarnation: POV-Ray for Unix
- Affected source version: v3.7.0.10 and current
master(6dd2dcab2464c1739940a7c7b42eb00b5a82feb1) - Known working source version: NA
Build Environment
- Operating system: macOS 15
- Hardware architecture: arm64
- Compiler: Apple Clang 17.0.0 (based on LLVM 19.1.4)
Build Command Sequence
# Built via Homebrew formula (also repro'd running build from local directory)
cd unix
./prebuild.sh
./configure COMPILED_BY=homebrew --disable-debug --disable-dependency-tracking --prefix=/opt/homebrew/Cellar/povray/3.7.0.10_14 --mandir=/opt/homebrew/Cellar/povray/3.7.0.10_14/share/man --with-boost=/opt/homebrew/opt/boost --with-openexr=/opt/homebrew/opt/openexr --without-libsdl --without-x
make install
Configure Output
===============================================================================
Configure POV-Ray version 3.7.0.10
===============================================================================
This is an unofficial version compiled by:
homebrew
The POV-Ray Team(tm) is not responsible for supporting this version.
Environment
-----------
checking build system type... aarch64-apple-darwin24.5.0
checking host system type... aarch64-apple-darwin24.5.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether sleep supports fractional seconds... yes
checking filesystem timestamp resolution... 2
checking whether build environment is sane... yes
/bin/sh: "/private/tmp/povray-20250811-31834-r6x7vu/povray-3.7.0.10/unix/config"/missing: No such file or directory
configure: WARNING: 'missing' script is too old or missing
checking for a race-free mkdir -p... mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking xargs -n works... yes
checking whether UID '501' is supported by ustar format... yes
checking whether GID '20' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether $C_INCLUDE_PATH contains the "." path... no
checking whether $CPLUS_INCLUDE_PATH contains the "." path... no
Programs
--------
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether clang accepts -g... yes
checking for clang option to enable C11 features... none needed
checking whether clang understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of clang... none
checking how to run the C preprocessor... clang -E
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking whether the compiler supports GNU C++... yes
checking whether clang++ accepts -g... yes
checking for clang++ option to enable C++11 features... none needed
checking dependency style of clang++... none
checking whether the clang++ compiler works... yes
checking how to run the C++ preprocessor... clang++ -E
checking for C++ compiler vendor... gnu
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for clang++ version... 17.0.0
checking for ranlib... ranlib
checking for stat format option... -f
Libraries
---------
checking whether to link with cygwin DLL... no
checking whether to enable static linking... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... -D_THREAD_SAFE
checking for boostlib >= 1.37... yes
checking whether the Boost::Thread library is available... yes
checking for exit in -lboost_thread... yes
checking whether the boost thread library is usable... yes
checking for sin in -lmkl... no
checking for sin in -lm... yes
checking for clock_gettime in -lrt... no
checking whether to use the ZLIB library... yes
checking for library containing zlibVersion... -lz
checking for zlib.h... yes
checking for libz version >= 1.2.1... 1.2.12, ok
checking whether to use the PNG library... yes
checking for library containing png_get_libpng_ver... -lpng
checking for png.h... yes
checking for libpng version >= 1.2.5... 1.6.50, ok
checking whether to use the JPEG library... yes
checking for library containing jpeg_std_error... -ljpeg
checking for jpeglib.h... yes
checking for libjpeg version >= 6b (62)... 80, ok
checking whether to use the TIFF library... yes
checking for library containing TIFFGetVersion... -ltiff
checking for tiffio.h... yes
checking for libtiff version >= 3.6.1... 4.7.0, ok
checking whether to use the OpenEXR library... yes
checking for pkg-config... pkg-config
checking for OpenEXR's pkg-config... yes
checking for OpenEXR version >= 1.2... 3.3.5, ok
checking for OpenEXR/ImfCRgbaFile.h... yes
checking for X... disabled
configure: X Window display will be disabled
Language constructs and functions
---------------------------------
checking for sys/time.h... yes
checking for time.h... yes
checking for limits.h... yes
checking for sys/resource.h... yes
checking for sys/time.h... (cached) yes
checking for unistd.h... (cached) yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking size of int... 4
checking size of long int... 8
checking size of size_t... 8
checking size of float... 4
checking for working memcmp... yes
checking for vsnprintf... yes
checking for getcwd... yes
checking for readlink... yes
checking for nanosleep... yes
checking for clock_gettime... yes
checking for getrusage... yes
checking for gettimeofday... yes
checking for asinh... yes
Compiling
---------
checking whether to enable pipes for communications... yes
checking whether clang++ accepts -pipe... yes
checking whether clang++ accepts -Wno-multichar... yes
checking whether clang++ accepts -Wno-write-strings... yes
checking whether clang++ accepts -fno-enforce-eh-specs... no
checking whether clang++ accepts -Wno-non-template-friend... no
checking whether to enable I/O restrictions... yes
checking whether to enable debugging... no
checking whether to enable profiling... no
checking whether to enable stripping... yes
checking whether clang++ accepts -s... no
configure: WARNING: Cannot set stripping mode
checking whether to enable optimizations... yes
checking whether clang++ accepts -O3... yes
checking whether clang++ accepts -ffast-math... yes
checking whether to enable architecture-specific optimizations... yes
checking which architecture to optimize for... aarch64-apple-darwin24.5.0
Makefiles
---------
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating source/Makefile
config.status: creating vfe/Makefile
config.status: creating unix/Makefile
config.status: creating unix/config.h
config.status: executing depfiles commands
===============================================================================
POV-Ray 3.7.0.10 has been configured.
Built-in features:
I/O restrictions: enabled
X Window display: disabled
Supported image formats: gif tga iff ppm pgm hdr png jpeg tiff openexr
Unsupported image formats: -
Compilation settings:
Build architecture: aarch64-apple-darwin24.5.0
Built/Optimized for: aarch64-apple-darwin24.5.0
Compiler vendor: gnu
Compiler version: clang++ 17.0.0
Compiler flags: -pipe -Wno-multichar -Wno-write-strings -O3 -ffast-math -D_THREAD_SAFE
Type 'make check' to build the program and run a test render.
Type 'make install' to install POV-Ray on your system.
The POV-Ray components will be installed in the following directories:
Program (executable): /opt/homebrew/Cellar/povray/3.7.0.10_14/bin
System configuration files: /opt/homebrew/Cellar/povray/3.7.0.10_14/etc/povray/3.7
User configuration files: /private/tmp/povray-20250811-31834-r6x7vu/povray-3.7.0.10/.brew_home/.povray/3.7
Standard include files: /opt/homebrew/Cellar/povray/3.7.0.10_14/share/povray-3.7/include
Standard INI files: /opt/homebrew/Cellar/povray/3.7.0.10_14/share/povray-3.7/ini
Standard demo scene files: /opt/homebrew/Cellar/povray/3.7.0.10_14/share/povray-3.7/scenes
Documentation (text, HTML): /opt/homebrew/Cellar/povray/3.7.0.10_14/share/doc/povray-3.7
Unix man page: /opt/homebrew/Cellar/povray/3.7.0.10_14/share/man
===============================================================================
Make Output
backend/shape/truetype.cpp:126:2: error: unknown type name 'Fixed'
126 | Fixed version; /* 0x10000 (1.0) */
| ^
backend/shape/truetype.cpp:151:2: error: unknown type name 'Fixed'
151 | Fixed version; /* for this table, set to 1.0 */
| ^
backend/shape/truetype.cpp:152:2: error: unknown type name 'Fixed'
152 | Fixed fontRevision; /* For Font Manufacturer */
| ^
backend/shape/truetype.cpp:192:2: error: unknown type name 'Fixed'
192 | Fixed version;
| ^
4 errors generated.
make[1]: *** [backend/shape/truetype.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [install-recursive] Error 1
Additional context (optional)
No issues with Xcode 16.2 or older
Workaround (optional)
Passing -include MacTypes.h to CXXFLAGS does allow build to succeed so I think header is not indirectly included in newer Xcode
Suggested Solution (optional)
Not too sure best solution but could modify logic at: https://github.com/POV-Ray/povray/blob/6dd2dcab2464c1739940a7c7b42eb00b5a82feb1/source/core/shape/truetype.cpp#L134-L135
Some ideas:
- Add
#include <MacTypes.h>on macOS. I think this is where Fixed is defined, or - Check for header guard (e.g.
defined(__MACTYPES__)).
But also, Fixed is a type that was introduced on the original Macintosh in 1984. It was defined for use with the fixed-point arithmetic utility routines FixRatio, FixMul, and FixRound described in Inside Macintosh I and which povray doesn't use. There's no reason why modern cross-platform software should be using such an ancient platform-specific type. It might be best to take ownership of your type, always define it, and rename it to something not currently or formerly used by an OS header.
TARGET_OS_MAC is defined in TargetOSMacros.def which was added in LLVM/Clang 18x - see https://github.com/llvm/llvm-project/pull/74676.
Prior to Clang 18, TARGET_OS_MAC was not defined - I believe because LLVM/Clang automatically adds -Werror,-Wundef-prefix=TARGET_OS_ as default compiler arguments.
Consequently, typedef int Fixed is skipped; hence the error.
A correction would be trivial
#if !defined(TARGET_OS_MAC) || (defined(__clang_major__) && __clang_major__ >= 18)
typedef int Fixed;
#endif
Cheers,
TARGET_OS_MACis defined in TargetOSMacros.def which was added in LLVM/Clang 18x - see llvm/llvm-project#74676.
You're talking about version 18 of llvm.org's llvm/clang, but Apple's llvm/clang (i.e. the one included with Xcode) has a different version numbering scheme. For example, Apple clang 17.0.0 was based on llvm.org's 19.1.4 release. So writing code that depends on compiler version numbers is tricky to get right. You'd need two cases—one for Apple's (when __apple_build_version__ is defined) and one for llvm.org's (when it isn't).
Also, checking whether TARGET_OS_MAC is defined is not how those types are usually used. Usually one checks instead whether they are true or false, after including <TargetConditionals.h>, after verifying that one is on an Apple platform.
Instead of that, I recommend the simple and obvious fix of renaming Fixed to something unique to povray and always defining it.
Other possible solutions I don't recommend:
Perhaps since Fixed is what was used by Apple when originally defining TrueType font structures, you want to keep using Apple's type on Apple platforms. The simple way to do that would be to include the header before you use the type (@cho-m's second suggestion), but while Fixed is declared in MacTypes.h, you can only include it as a top-level header on OS X 10.8 and later; prior to that it was only available in the CarbonCore framework, which is part of the CoreServices framework. Joshua Root says including the CoreServices umbrella header is the Right Way to get Carbon types:
#ifdef __APPLE__
#include <CoreServices/CoreServices.h>
#else
typedef int Fixed;
#endif
But be aware that MacTypes.h, like all of Carbon, was deprecated in 2012, so I do not recommend relying on it. It could go away at any time.
The alternative used by Homebrew was to check if the MacTypes.h include guard macro is defined (@cho-m's first suggestion):
#ifndef __MACTYPES__
typedef int Fixed;
#endif
This works at present but I'm not a fan of relying on implementation details of someone else's header. Apple could rename those include guards at any time.
I recommend the https://github.com/POV-Ray/povray/issues/479#issuecomment-3384288199 of renaming Fixed to something unique to povray and always defining it.
This fix seems also trivial as the Fixed type seems to only be used a few places in truetype.cpp.
Cheers,