[MacPorts] #70331: gcc14 (c++) can not compile trivial program

MacPorts noreply at macports.org
Sun Jul 7 01:46:23 UTC 2024


#70331: gcc14 (c++) can not compile trivial program
----------------------+--------------------
  Reporter:  acmaggs  |      Owner:  (none)
      Type:  defect   |     Status:  new
  Priority:  Normal   |  Milestone:
 Component:  ports    |    Version:
Resolution:           |   Keywords:
      Port:  gcc14    |
----------------------+--------------------

Comment (by mouse07410):

 Apple Silicon M2 MacBook Pro, running MacOS Sonoma 14.5. Latest Xcode
 installed (15.4).
 With SDKROOT and CFLAGS not set:
 {{{
 $ cat hello.c
 #include <stdio.h>

 int main(int argc, char *argv[])
 {
         printf("Hello, world!\n");
         return 0;
 }
 $
 $ gcc-mp-12 -o h hello.c
 $ ./h
 Hello, world!
 $ gcc-mp-13 -o h hello.c
 $ ./h
 Hello, world!
 $ gcc-mp-14 -o h hello.c
 In file included from hello.c:1:
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:153: error: macro "__API_AVAILABLE4" requires 5
 arguments, but only 4 given
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |
 ^
 In file included from
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/Availability.h:177,
                  from
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/_stdio.h:69,
                  from /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0
 /include-fixed/stdio.h:78:
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/AvailabilityInternal.h:257:13: note: macro "__API_AVAILABLE4"
 defined here
   257 |     #define __API_AVAILABLE4(arg0,arg1,arg2,arg3,arg4)
 __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4)
       |             ^~~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h: In function 'fmemopen':
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:88: error: expected declaration specifiers before
 '__API_AVAILABLE4'
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |
 ^~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:384:119: error: macro "__API_AVAILABLE4" requires 5
 arguments, but only 4 given
   384 | FILE *open_memstream(char **__bufp, size_t *__sizep)
 __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
       |
 ^
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/AvailabilityInternal.h:257:13: note: macro "__API_AVAILABLE4"
 defined here
   257 |     #define __API_AVAILABLE4(arg0,arg1,arg2,arg3,arg4)
 __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4)
       |             ^~~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:384:54: error: expected '=', ',', ';', 'asm' or
 '__attribute__' before '__API_AVAILABLE4'
   384 | FILE *open_memstream(char **__bufp, size_t *__sizep)
 __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
       |
 ^~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:394:20: error: storage class specified for parameter
 'sys_nerr'
   394 | extern __const int sys_nerr;            /* perror(3) external
 variables */
       |                    ^~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:395:30: error: storage class specified for parameter
 'sys_errlist'
   395 | extern __const char *__const sys_errlist[];
       |                              ^~~~~~~~~~~
 In file included from /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0
 /include-fixed/stdio.h:433:
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/secure/_stdio.h:42:12:
 error: storage class specified for parameter '__sprintf_chk'
    42 | extern int __sprintf_chk (char * __restrict, int, size_t,
       |            ^~~~~~~~~~~~~
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/secure/_stdio.h:52:12:
 error: storage class specified for parameter '__snprintf_chk'
    52 | extern int __snprintf_chk (char * __restrict, size_t, int, size_t,
       |            ^~~~~~~~~~~~~~
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/secure/_stdio.h:61:12:
 error: storage class specified for parameter '__vsprintf_chk'
    61 | extern int __vsprintf_chk (char * __restrict, int, size_t,
       |            ^~~~~~~~~~~~~~
 /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/secure/_stdio.h:70:12:
 error: storage class specified for parameter '__vsnprintf_chk'
    70 | extern int __vsnprintf_chk (char * __restrict, size_t, int,
 size_t,
       |            ^~~~~~~~~~~~~~~
 hello.c:4:1: error: expected '=', ',', ';', 'asm' or '__attribute__'
 before '{' token
     4 | {
       | ^
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:7: error: old-style parameter declarations in prototyped
 function definition
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |       ^~~~~~~~
 hello.c:8: error: expected '{' at end of input
 $
 }}}

 Setting SDKROOT:
 {{{
 $ xcode-select -p
 /Applications/Xcode.app/Contents/Developer
 $ ll
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
 total 0
 drwxr-xr-x  5 root  wheel  160 May 14 10:53 ./
 drwxr-xr-x  6 root  wheel  192 May  8 06:21 ../
 drwxr-xr-x  7 root  wheel  224 Apr 25 14:57 MacOSX.sdk/
 lrwxr-xr-x  1 root  wheel   10 May 14 10:51 MacOSX14.5.sdk@ -> MacOSX.sdk
 lrwxr-xr-x  1 root  wheel   10 May 14 10:51 MacOSX14.sdk@ -> MacOSX.sdk
 $ export
 SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
 $ ll
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
 total 40
 drwxr-xr-x  7 root  wheel   224 Apr 25 14:57 ./
 drwxr-xr-x  5 root  wheel   160 May 14 10:53 ../
 -rw-r--r--  1 root  wheel   127 Apr 13 09:39 Entitlements.plist
 -rw-r--r--  1 root  wheel  6613 Apr 13 09:39 SDKSettings.json
 -rw-r--r--  1 root  wheel  4885 Apr 13 09:39 SDKSettings.plist
 drwxr-xr-x  5 root  wheel   160 Apr 25 14:53 System/
 drwxr-xr-x  7 root  wheel   224 Apr 25 14:53 usr/
 $ gcc-mp-13 -o h hello.c
 $ ./h
 Hello, world!
 $ gcc-mp-14 -o h hello.c
 In file included from hello.c:1:
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:153: error: macro "__API_AVAILABLE4" requires 5
 arguments, but only 4 given
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |
 ^
 In file included from
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/Availability.h:177,
                  from
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:69,
                  from /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0
 /include-fixed/stdio.h:78:
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/AvailabilityInternal.h:257:13: note: macro "__API_AVAILABLE4"
 defined here
   257 |     #define __API_AVAILABLE4(arg0,arg1,arg2,arg3,arg4)
 __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4)
       |             ^~~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h: In function 'fmemopen':
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:88: error: expected declaration specifiers before
 '__API_AVAILABLE4'
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |
 ^~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:384:119: error: macro "__API_AVAILABLE4" requires 5
 arguments, but only 4 given
   384 | FILE *open_memstream(char **__bufp, size_t *__sizep)
 __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
       |
 ^
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/AvailabilityInternal.h:257:13: note: macro "__API_AVAILABLE4"
 defined here
   257 |     #define __API_AVAILABLE4(arg0,arg1,arg2,arg3,arg4)
 __API_A(arg0) __API_A(arg1) __API_A(arg2) __API_A(arg3) __API_A(arg4)
       |             ^~~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:384:54: error: expected '=', ',', ';', 'asm' or
 '__attribute__' before '__API_AVAILABLE4'
   384 | FILE *open_memstream(char **__bufp, size_t *__sizep)
 __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
       |
 ^~~~~~~~~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:394:20: error: storage class specified for parameter
 'sys_nerr'
   394 | extern __const int sys_nerr;            /* perror(3) external
 variables */
       |                    ^~~~~~~~
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:395:30: error: storage class specified for parameter
 'sys_errlist'
   395 | extern __const char *__const sys_errlist[];
       |                              ^~~~~~~~~~~
 In file included from /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0
 /include-fixed/stdio.h:433:
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:42:12:
 error: storage class specified for parameter '__sprintf_chk'
    42 | extern int __sprintf_chk (char * __restrict, int, size_t,
       |            ^~~~~~~~~~~~~
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:52:12:
 error: storage class specified for parameter '__snprintf_chk'
    52 | extern int __snprintf_chk (char * __restrict, size_t, int, size_t,
       |            ^~~~~~~~~~~~~~
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:61:12:
 error: storage class specified for parameter '__vsprintf_chk'
    61 | extern int __vsprintf_chk (char * __restrict, int, size_t,
       |            ^~~~~~~~~~~~~~
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:70:12:
 error: storage class specified for parameter '__vsnprintf_chk'
    70 | extern int __vsnprintf_chk (char * __restrict, size_t, int,
 size_t,
       |            ^~~~~~~~~~~~~~~
 hello.c:4:1: error: expected '=', ',', ';', 'asm' or '__attribute__'
 before '{' token
     4 | {
       | ^
 /opt/local/lib/gcc14/gcc/arm64-apple-darwin23/14.1.0/include-
 fixed/stdio.h:383:7: error: old-style parameter declarations in prototyped
 function definition
   383 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char
 * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0),
 watchos(4.0));
       |       ^~~~~~~~
 hello.c:8: error: expected '{' at end of input
 $
 }}}

 In other words, very similar experience to what others reported.

-- 
Ticket URL: <https://trac.macports.org/ticket/70331#comment:13>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list