Category Archives: C++

Anything related to the C++ programming language

Programming — Principles and Practice Using C++, 2nd edition

I got my copy of “Programming — Principles and Practice Using C++”, second edition, today. My copy is of the third printing, dated June 2015, so it’s a pretty recent printing.

I’m not teaching programming nor C++ at my school, although I used to. My job is simply to be the school’s system administrator, but the odd guest lecture and other lecture invitations has popped up from time to time over the past 16 years. I’ve known C++ since 1994, and the language and its libraries has changed at lot over the years. Maybe Prof. Dr. Stroustrup’s teaching style will have an impact on my own teaching style. Continue reading Programming — Principles and Practice Using C++, 2nd edition

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