首頁 > 後端開發 > C++ > 為什麼我的 C 程式碼在升級到 Catalina 後無法使用 `` 標頭進行編譯?

為什麼我的 C 程式碼在升級到 Catalina 後無法使用 `` 標頭進行編譯?

Patricia Arquette
發布: 2024-11-15 10:15:02
原創
635 人瀏覽過

Why is my C++ code failing to compile with the `` header after upgrading to Catalina?

Catalina C++: Header Error: Undefined 'signbit' Member

Introduction

Upgrading to Catalina from Mojave can introduce issues when compiling programs that rely on the header. This is due to a change in how the system libraries are handled in Catalina.

Problem Statement

After the upgrade, attempting to compile code using the header results in errors such as:

error: no member named 'signbit' in the global namespace
error: no member named 'fpclassify' in the global namespace
error: no member named 'isfinite' in the global namespace
登入後複製

Cause

Catalina purges and protects the /usr/include directory, which is where the C headers are typically found. As a result, build systems may fail to locate the necessary headers.

Solution

To resolve this issue, it is necessary to point the build system to the correct headers using the -isysroot compiler flag. Here are the steps to do so:

  1. Verify that Xcode is up to date.
  2. Determine the system SDK path using xcrun --show-sdk-path, and modify the build system accordingly:

    • CMake: set(CMAKE_OSX_SYSROOT /sdk/path) or set(CMAKE_CXX_FLAGS "[...] -isysroot /sdk/path")
    • Other compilers: Add -isysroot /sdk/path to the compiler flags

Conclusion

Following these steps should resolve the issue and allow programs using the header to compile successfully under Catalina.

以上是為什麼我的 C 程式碼在升級到 Catalina 後無法使用 `` 標頭進行編譯?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板