Clang For Mac Os X



The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation of these languages. Clang builds on the LLVM optimizer and code generator, allowing it to provide high-quality optimization and code generation support for many targets.

About the App

  • App name: clang-format
  • App description: C/C++/Obj-C formatting tools: standalone and editor plugins
  • App website: http://clang.llvm.org/docs/ClangFormat.html
  • Like Python, it's easy to set up C in OS X. Mostly because it's already packaged in the system and you don't need to install anything. Open terminal and enter clang -version. Clang is the compiler.
  • Question: Q: How to obtain a GCC on Mac OS X 10.11.6 I have to start coding in C next term (for school) and all of the tutorials on how to install a GCC compiler on Mac involve getting the Xcode app. Unfortunately, whenever I go to download it, it tells me 'Xcode can’t be installed on “Macintosh HD” because OS X version 10.12.6 or later.
  • 1: Neither OS X nor Xcode comes with real GCC. For compatibility with scripts which assume the compiler is called “gcc”, it has executables by that name, but they are all fronts for Clang. No amount of symlinking, setting environment variables, or setting up aliases will allow those executables to run real GCC.
  • A recent (and even more recently reverted) change to Homebrew highlighted an interesting (read: maddening) quirk of clang on OS X. Here’s the background. When you compile something using clang on OS X there are (roughly speaking) two stages to the compile. In the first, your source code is loaded and the compiler searches its include paths to find your includes.
Mac

Install the App

  1. Press Command+Space and type Terminal and press enter/return key.
  2. Run in Terminal app:
    ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)' < /dev/null 2> /dev/null
    and press enter/return key.
    If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
  3. Run:
    brew install clang-format

Clang For Mac Os X Download

Done! You can now use clang-format.

Similar Software for Mac

Clang-format

Llvm Mac Os X

Clang For Mac Os XMacClang For Mac Os X

The Xcode-provided Clang appears not be bring along the include files needed for plugins, so LibreOffice never ran its set of Clang plugins when building on Mac OS X. Until now.

What works is to build a local copy of Clang, e.g., from trunk with the script

where --enable-keep-symbols is important on OS X so that the
clang/clang++ executables do export all the symbols
referenced by plugins.

Current Clang trunk has one bug that is triggered by the internal copy of
python3 in LibreOffice, “Concatenated Objective C format string triggers Sema::CheckFormatString ‘String literal not of constant array type!” assert,“ a workaround is to apply the patch

to tools/clang.

Update Clang Mac Os X

On recent LibreOffice trunk, with “Allow building compilerplugins/clang on Mac OS X” and “Drop CLANGBUILD in addition to CLANGDIR”, when doing a build of the 64-bit, ≥ 10.8 variant, add

Clang-format For Mac Os X

to autogen.input. That is, look at the values assigned to CC and CXX in config_host.mk after a plain ./autogen.sh, replace the path to clang resp. clang++, and add the include path to the Xcode libc++ headers to CXX. (You can likely also drop the implicit -m64 and -stdlib=libc++.)

Clang Mac Os X Install

And that’s it.





Comments are closed.