如何在 Mac 中使用 CMake 3.28 编译 C++ 模块项目

问题描述 投票:0回答:1

我在 Mac 上的 CLion 中有一个简单的程序,无法使用 cmake 版本 3.28 进行编译。当我切换到 cmake 版本 3.27 时,一切正常。

如何启用3.28版本?根据 cmake 网站,3.28 中添加了对模块的支持。我什至无法使用 cmake 3.28 编译 cpp 文件。

以下是我正在使用的版本:

... ~ % cmake --version
cmake version 3.30.5

CMake suite maintained and supported by Kitware (kitware.com/cmake).
... ~ % g++ --version
g++-14 (Homebrew GCC 14.2.0) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

... ~ % 

这是代码:

// main.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

如果我使用以下

CMakeLists.txt
,一切正常:

cmake_minimum_required(VERSION 3.27)
project(cpp)

set(CMAKE_CXX_STANDARD 23)

add_executable(cpp main.cpp)

如果我将版本更改为 3.28,一切都会崩溃:

// CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(cpp)

set(CMAKE_CXX_STANDARD 23)

add_executable(cpp main.cpp)

这是错误日志:

====================[ Build | cpp | Debug ]=====================================
/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --build /Users/aakashgupta/Documents/personal_finance/cpp/cmake-build-debug --target cpp -j 6
[0/1] Re-running CMake...
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/aakashgupta/Documents/personal_finance/cpp/cmake-build-debug
[2/4] Building CXX object CMakeFiles/cpp.dir/main.cpp.o
FAILED: CMakeFiles/cpp.dir/main.cpp.o 
/opt/homebrew/Cellar/gcc/14.2.0/bin/g++-14   -g -std=gnu++23 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk -fdiagnostics-color=always -MD -MT CMakeFiles/cpp.dir/main.cpp.o -MF CMakeFiles/cpp.dir/main.cpp.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/cpp.dir/main.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/cpp.dir/main.cpp.o -c /Users/aakashgupta/Documents/personal_finance/cpp/main.cpp
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/machine/_types.h:34,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/sys/_types.h:33,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_types.h:27,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:70,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/wchar.h:67,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:44,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/postypes.h:40,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/iosfwd:42,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ios:40,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ostream:40,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/iostream:41,
                 from /Users/aakashgupta/Documents/personal_finance/cpp/main.cpp:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/arm/_types.h:75:9: error: 'ptrdiff_t' does not name a type
   75 | typedef ptrdiff_t               __darwin_ptrdiff_t;     /* ptr1 - ptr2 */
      |         ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/arm/_types.h:20:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   19 | #include <sys/_types/_wchar_t.h>
  +++ |+#include <cstddef>
   20 | #endif
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/arm/_types.h:85:9: error: 'size_t' does not name a type
   85 | typedef size_t                  __darwin_size_t;        /* sizeof() */
      |         ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/arm/_types.h:85:9: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /opt/homebrew/Cellar/gcc/14.2.0/lib/gcc/current/gcc/aarch64-apple-darwin24/14/include-fixed/stdio.h:75,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:90:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:245:1: error: 'size_t' does not name a type
  245 | size_t   fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:162:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  161 | #include <sys/_types/_seek_set.h>
  +++ |+#include <cstddef>
  162 | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:252:1: error: 'size_t' does not name a type
  252 | size_t   fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:252:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:270:61: error: 'size_t' has not been declared
  270 | int      setvbuf(FILE * __restrict, char * __restrict, int, size_t);
      |                                                             ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:431:44: error: 'size_t' has not been declared
  431 | int      snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4);
      |                                            ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:434:45: error: 'size_t' has not been declared
  434 | int      vsnprintf(char * __restrict __str, size_t __size, const char * __restrict __format, va_list) __printflike(3, 0);
      |                                             ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:451:46: error: 'size_t' has not been declared
  451 | ssize_t getdelim(char ** __restrict __linep, size_t * __restrict __linecapp, int __delimiter, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                              ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:452:45: error: 'size_t' has not been declared
  452 | ssize_t getline(char ** __restrict __linep, size_t * __restrict __linecapp, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                             ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:453:41: error: 'size_t' has not been declared
  453 | 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));
      |                                         ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:454:37: error: 'size_t' has not been declared
  454 | FILE *open_memstream(char **__bufp, size_t *__sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                     ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_stdio.h:469:25: error: 'size_t' has not been declared
  469 | char    *fgetln(FILE *, size_t *);
      |                         ^~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/time.h:63,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:91:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_time.h:116:1: error: 'size_t' does not name a type
  116 | size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict) __DARWIN_ALIAS(strftime);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_time.h:74:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   73 | #include <sys/_types/_timespec.h>
  +++ |+#include <cstddef>
   74 | 
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_ctype.h:71,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/ctype.h:66,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/___wctype.h:72,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/__wctype.h:39,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:92:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/runetype.h:81:53: error: '__darwin_size_t' has not been declared
   81 |         __darwin_rune_t (*__sgetrune)(const char *, __darwin_size_t, char const **);
      |                                                     ^~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/runetype.h:82:64: error: '__darwin_size_t' has not been declared
   82 |         int             (*__sputrune)(__darwin_rune_t, char *, __darwin_size_t, char **);
      |                                                                ^~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:107:1: error: 'size_t' does not name a type
  107 | size_t  mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:93:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   92 | #include <__wctype.h>
  +++ |+#include <cstddef>
   93 | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:108:1: error: 'size_t' does not name a type
  108 | size_t  mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:108:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:111:1: error: 'size_t' does not name a type
  111 | size_t  mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:111:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:115:40: error: 'size_t' has not been declared
  115 | int     swprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict, ...);
      |                                        ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:120:41: error: 'size_t' has not been declared
  120 | int     vswprintf(wchar_t * __restrict, size_t, const wchar_t * __restrict,
      |                                         ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:123:1: error: 'size_t' does not name a type
  123 | size_t  wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:123:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:129:1: error: 'size_t' does not name a type
  129 | size_t  wcscspn(const wchar_t *, const wchar_t *);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:129:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:130:1: error: 'size_t' does not name a type
  130 | size_t  wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:130:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:132:1: error: 'size_t' does not name a type
  132 | size_t  wcslen(const wchar_t *);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:132:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:133:68: error: 'size_t' has not been declared
  133 | wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, size_t);
      |                                                                    ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:134:51: error: 'size_t' has not been declared
  134 | int     wcsncmp(const wchar_t *, const wchar_t *, size_t);
      |                                                   ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:135:69: error: 'size_t' has not been declared
  135 | wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t);
      |                                                                     ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:138:1: error: 'size_t' does not name a type
  138 | size_t  wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:138:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:140:1: error: 'size_t' does not name a type
  140 | size_t  wcsspn(const wchar_t *, const wchar_t *);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:140:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:142:1: error: 'size_t' does not name a type
  142 | size_t  wcsxfrm(wchar_t * __restrict, const wchar_t * __restrict, size_t);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:142:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:150:44: error: 'size_t' has not been declared
  150 | wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
      |                                            ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:151:51: error: 'size_t' has not been declared
  151 | int     wmemcmp(const wchar_t *, const wchar_t *, size_t);
      |                                                   ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:152:68: error: 'size_t' has not been declared
  152 | wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
      |                                                                    ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:153:47: error: 'size_t' has not been declared
  153 | wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
      |                                               ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:154:38: error: 'size_t' has not been declared
  154 | wchar_t *wmemset(wchar_t *, wchar_t, size_t);
      |                                      ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:157:35: error: 'size_t' has not been declared
  157 | int     wcswidth(const wchar_t *, size_t);
      |                                   ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:195:1: error: 'size_t' does not name a type
  195 | size_t  mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:195:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:198:68: error: 'size_t' has not been declared
  198 | wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                                    ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:201:55: error: 'size_t' has not been declared
  201 | int     wcsncasecmp(const wchar_t *, const wchar_t *, size_t n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                                       ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:202:1: error: 'size_t' does not name a type
  202 | size_t  wcsnlen(const wchar_t *, size_t) __pure __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:202:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:203:1: error: 'size_t' does not name a type
  203 | size_t  wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:203:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:205:42: error: 'size_t' has not been declared
  205 | FILE *open_wmemstream(wchar_t ** __bufp, size_t * __sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                          ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:215:37: error: 'size_t' has not been declared
  215 | wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
      |                                     ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:216:1: error: 'size_t' does not name a type
  216 | size_t  wcslcat(wchar_t *, const wchar_t *, size_t);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:216:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:217:1: error: 'size_t' does not name a type
  217 | size_t  wcslcpy(wchar_t *, const wchar_t *, size_t);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_wchar.h:217:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:153:11: error: 'mbrlen' has not been declared in '::'
  153 |   using ::mbrlen;
      |           ^~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:154:11: error: 'mbrtowc' has not been declared in '::'
  154 |   using ::mbrtowc;
      |           ^~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:156:11: error: 'mbsrtowcs' has not been declared in '::'
  156 |   using ::mbsrtowcs;
      |           ^~~~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:178:11: error: 'wcrtomb' has not been declared in '::'
  178 |   using ::wcrtomb;
      |           ^~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:183:11: error: 'wcscspn' has not been declared in '::'
  183 |   using ::wcscspn;
      |           ^~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:184:11: error: 'wcsftime' has not been declared in '::'
  184 |   using ::wcsftime;
      |           ^~~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:185:11: error: 'wcslen' has not been declared in '::'
  185 |   using ::wcslen;
      |           ^~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:189:11: error: 'wcsrtombs' has not been declared in '::'
  189 |   using ::wcsrtombs;
      |           ^~~~~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:190:11: error: 'wcsspn' has not been declared in '::'
  190 |   using ::wcsspn;
      |           ^~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/cwchar:198:11: error: 'wcsxfrm' has not been declared in '::'
  198 |   using ::wcsxfrm;
      |           ^~~~~~~
In file included from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/exception_ptr.h:36,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/exception:166,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ios:41:
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/cxxabi_init_exception.h:63:32: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
   63 |       __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW;
      |                                ^~~~~~
      |                                std::size_t
In file included from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/requires_hosted.h:31,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/iostream:38:
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/aarch64-apple-darwin24/bits/c++config.h:310:33: note: 'std::size_t' declared here
  310 |   typedef __SIZE_TYPE__         size_t;
      |                                 ^~~~~~
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/exception_ptr.h: In function 'std::__exception_ptr::exception_ptr std::make_exception_ptr(_Ex)':
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/exception_ptr.h:253:55: error: '__cxxabiv1::__cxa_allocate_exception' cannot be used as a function
  253 |       void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex));
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ios:42:
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/char_traits.h: In static member function 'static constexpr std::size_t std::char_traits<wchar_t>::length(const char_type*)':
/opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/char_traits.h:522:16: error: 'wcslen' was not declared in this scope
  522 |         return wcslen(__s);
      |                ^~~~~~
In file included from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/aarch64-apple-darwin24/bits/gthr-default.h:35,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/aarch64-apple-darwin24/bits/gthr.h:157,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ext/atomicity.h:35,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/bits/ios_base.h:39,
                 from /opt/homebrew/Cellar/gcc/14.2.0/include/c++/14/ios:44:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h: At global scope:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:236:66: error: 'size_t' has not been declared
  236 | int pthread_attr_getguardsize(const pthread_attr_t * __restrict, size_t * __restrict);
      |                                                                  ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:253:57: error: 'size_t' has not been declared
  253 |                 void * _Nullable * _Nonnull __restrict, size_t * __restrict);
      |                                                         ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:260:66: error: 'size_t' has not been declared
  260 | int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict);
      |                                                                  ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:269:49: error: 'size_t' has not been declared
  269 | int pthread_attr_setguardsize(pthread_attr_t *, size_t);
      |                                                 ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:285:53: error: 'size_t' has not been declared
  285 | int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
      |                                                     ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:291:49: error: 'size_t' has not been declared
  291 | int pthread_attr_setstacksize(pthread_attr_t *, size_t);
      |                                                 ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:531:44: error: 'size_t' has not been declared
  531 | int     pthread_getname_np(pthread_t,char*,size_t);
      |                                            ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:546:1: error: 'size_t' does not name a type
  546 | size_t pthread_get_stacksize_np(pthread_t);
      | ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:76:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   75 | #include <sys/_types/_sigset_t.h>
  +++ |+#include <cstddef>
   76 | 
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/pthread.h:746:23: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
  746 | pthread_cpu_number_np(size_t *cpu_number_out);
      |                       ^~~~~~
      |                       std::size_t
...
ninja: build stopped: subcommand failed.
macos cmake c++-modules
1个回答
0
投票

尝试在您的

CMakeLists.txt
中添加此行:

add_compile_options(-include cstddef)
© www.soinside.com 2019 - 2024. All rights reserved.