Category Archives: clang

CPUTYPE woes with editors/emacs on FreeBSD/i386 stable/10

On my FreeBSD/i386 stable/10 and head VMs I have set up clang as the system compiler.

CC=clang
CXX=clang++
CPP=clang-cpp

KERNCONF=VBOX

I have also set CPUTYPE to corei7 as this is accepted by clang and pretty much describes the capabilities of the host system.

CPUTYPE?=corei7

Continue reading CPUTYPE woes with editors/emacs on FreeBSD/i386 stable/10

Detecting clang in C code

If you’re looking for a way to detect when your code is being compiled by clang, try the command

clang -dM -E -x c /dev/null

In the large list presented, you’ll find these macros the most interesting ones:

#define __clang__ 1
#define __clang_major__ 3
#define __clang_minor__ 3
#define __clang_patchlevel__ 0
#define __clang_version__ "3.3 (tags/RELEASE_33/final 183502)"
#define __llvm__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __VERSION__ "4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502)"

Continue reading Detecting clang in C code