Home > database >  macOS: C 11 Compilation Error with Apple clang Version 13 In Terminal but not In Xcode
macOS: C 11 Compilation Error with Apple clang Version 13 In Terminal but not In Xcode

Time:01-12

I'm trying to run an example from Microsoft Docs on delegating constructors in C . For small bits of code like this, I like to use VS Code, but when I use my usual make command in the terminal I get the error,

error: delegating constructors are permitted only in C 11

I do not get this error when I run the same code in Xcode.

Why can't I run this in the terminal? My Xcode stuff, including command line tools, is up to date so is there something else I'm missing?

Edit

If I enter g --version in the terminal I get,

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c  /4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

CodePudding user response:

You need to add --std=c 11 to the g command line options in your Makefile. Visual Studio defaults to the latest possible C standard. gcc defaults to the earliest.

  •  Tags:  
  • Related