-3

I'm using Clion and GCC on macOS Sequoia. And, when I tried to compile a source code, it keeps making this compile error.

GCC version : gcc (Homebrew GCC 14.1.0_1) 14.1.0

Apple Clang version : Apple clang version 16.0.0 (clang-1600.0.20.10)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Clion version : 2024.2 EAP (242.19890.26)

#pragma GCC optimize("O3", "unroll-loops", "fast-math", "Ofast", "inline")

#include <iostream>
int main(){
   std::cout << "Hello World!" << std::endl;
   return 0;
}

An error occurred even when I tried to compile a simple code like this.

/Users/user/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake --build /Users/user/CLionProjects/untitled/cmake-build-gcc --target untitled -j 6
[1/2] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
FAILED: CMakeFiles/untitled.dir/main.cpp.o 
/opt/homebrew/opt/gcc/bin/g++-14  -I/opt/homebrew/opt/boost/include -I/opt/homebrew/opt/eigen/include/eigen3 -I/opt/homebrew/opt/gmp/include -I/Users/user/CLionProjects/untitled/include -g -std=gnu++23 -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -fdiagnostics-color=always -MD -MT CMakeFiles/untitled.dir/main.cpp.o -MF CMakeFiles/untitled.dir/main.cpp.o.d -o CMakeFiles/untitled.dir/main.cpp.o -c /Users/user/CLionProjects/untitled/main.cpp
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_wchar.h:90,
                 from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/wchar.h:70,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/cwchar:44,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/bits/postypes.h:40,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/iosfwd:42,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/ios:40,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/ostream:40,
                 from /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/iostream:41,
                 from /Users/user/CLionProjects/untitled/main.cpp:3:
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:315:31: error: macro "getchar_unlocked" passed 1 arguments, but takes just 0
  315 | int      getchar_unlocked(void);
      |                               ^
In file included from /opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:78:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:408:9: note: macro "getchar_unlocked" defined here
  408 | #define getchar_unlocked()      getc_unlocked(stdin)
      |         ^~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:285:28: error: redefinition of 'int __sputc(int, FILE*)'
  285 | __header_always_inline int __sputc(int _c, FILE *_p) {
      |                            ^~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:356:28: note: 'int __sputc(int, FILE*)' previously defined here
  356 | __header_always_inline int __sputc(int _c, FILE *_p) {
      |                            ^~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:314:10: error: expected unqualified-id before '--' token
  314 | int      getc_unlocked(FILE *);
      |          ^~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:314:10: error: expected ')' before '--' token
  314 | int      getc_unlocked(FILE *);
      |          ^~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:315:10: error: 'int getchar_unlocked' redeclared as different kind of entity
  315 | int      getchar_unlocked(void);
      |          ^~~~~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:386:10: note: previous declaration 'int getchar_unlocked()'
  386 | int      getchar_unlocked(void);
      |          ^~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:316:10: error: conflicting declaration of 'int __sputc(int, FILE*)' with 'C' linkage
  316 | int      putc_unlocked(int, FILE *);
      |          ^~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:356:28: note: previous declaration with 'C++' linkage
  356 | __header_always_inline int __sputc(int _c, FILE *_p) {
      |                            ^~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:317:10: error: '__stdoutp' is not a type
  317 | int      putchar_unlocked(int);
      |          ^~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/current/gcc/aarch64-apple-darwin23/14/include-fixed/stdio.h:317:10: error: conflicting declaration of C function 'int __sputc(int, int)'
  317 | int      putchar_unlocked(int);
      |          ^~~~~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:356:28: note: previous declaration 'int __sputc(int, FILE*)'
  356 | __header_always_inline int __sputc(int _c, FILE *_p) {
      |                            ^~~~~~~
ninja: build stopped: subcommand failed.
9
  • 1
    Can you provide a minimal reproducible example of source code that leads to this error?
    – Chris
    Commented Jul 9 at 22:49
  • 3
    Start with something incredibly stupid like Hello World and build with g++ hello.cpp. If that's enough for a minimal reproducible example, you have a configuration problem on your computer, and those are an absolute <expletive deleted> to solve without access to the PC. Commented Jul 9 at 23:12
  • 1
    GNU and Apple Clang C standard libraries are mixed and conflicting. Uninstall gcc, you have a nice compiler apple clang.
    – 3CxEZiVlQ
    Commented Jul 9 at 23:18
  • 1
    Please provide enough code so others can better understand or reproduce the problem.
    – Community Bot
    Commented Jul 10 at 1:01
  • 4
    Do NOT use bits/stdc++
    – ChrisMM
    Commented Jul 10 at 1:27

0

Browse other questions tagged or ask your own question.