Can't compile C program on a Mac after upgrade to Mojave

前端 未结 15 701
陌清茗
陌清茗 2020-11-22 06:58

I have used the gcc command on the terminal to compile C programs but all of a sudden, after an update to my Mac\'s OS (to macOS 10.14 Mojave, and XCode 10.0), I started rec

15条回答
  •  太阳男子
    2020-11-22 07:33

    Had similar problems as the OP

    Issue

    cat hello.c

    #include 
    int main() { exit(0); }
    

    clang hello.c

    /usr/local/include/stdint.h:2:10: error: #include nested too deeply
    etc...
    

    Attempted fix

    I installed the latest version of XCode, however, release notes indicated the file mentioned in the previous fix, from Jonathan here, was no longer available.

    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
    

    Details here https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes , under the New Features section.


    Solution that worked for me...

    Using details in this comment, https://github.com/SOHU-Co/kafka-node/issues/881#issuecomment-396197724

    I found that brew doctor reported I had unused includes in my /usr/local/ folder.

    So to fix, I used the command provided by user HowCrazy , to find the unused includes and move them to a temporary folder.

    Repeated here...

    mkdir /tmp/includes
    brew doctor 2>&1 | grep "/usr/local/include" | awk '{$1=$1;print}' | xargs -I _ mv _ /tmp/includes
    

    After running the scripts, the include file issue was gone. nb: I commented on this issue here too.

提交回复
热议问题