December 2014

A Video Interview with C++ Author John Lakos

lakos-cppcon.PNGA video published on InformIT in which author talks about various concepts/aspects of C++.

A Video Interview with C++ Author John Lakos

John Lakos, author of Large-Scale C++ LiveLessons (Workshop): Applied Hierarchical Reuse Using Bloomberg's Foundation Libraries and senior software architect at Bloomberg, talks with Brian Overland about applied hierarchical reuse, the problem with undefined behavior, the use of macros in C++, the importance of using the right tool for the job, and the challenge of getting people to do things your way.

Developing Native-Activity (Android) C++ applications -- Ankit Asthana

vs-native-activity.PNGMore support for creating all-C++ Android applications:

Developing Native-Activity (Android) applications in Visual Studio 2015

by Ankit Asthana

From the article:

Visual Studio 2015 preview (download here) introduces the ability for developers to create Android Native Activity application as a part of the cross-platform mobile development. Android platform with Android Native Activity (API Level 9) introduced the capability to create pure C/C++ applications. While there is some hidden Java JNI code in the background the idea is to abstract this detail away from the developer. Native Activity applications are popular for gaming (e.g. Unreal 4) and graphic intensive (OpenGL) applications. This post will guide you through the experience of creating a Native Activity application and walking through the developer lifecycle of editing, building and debugging Native Activity code...

Background: The Android NDK was first released in 2009 offering the possibility to use C++ code in Android applications. Since NDK 5 (released in Dec 2010) it is even possible to create a complete native Android app in C++ but even with the continuous improvements of the SDK/NDK it was easier to develop Android applications in Java than in C++.

Top 5 Beautiful C++ STD Algorithms Examples--Bartlomiej Filipek

Bartlomiej Filipek shares with us five algorithms using the C++ STD:

Top 5 Beautiful C++ STD Algorithms Examples

by Bartlomiej Filipek

From the article:

Some time ago I've seen an inspiring talk from CppCon 2013: "C++ Seasoning" by Sean Parent. One of the main points of this presentation was not to use raw loops. Instead, prefer to use existing algorithms or write functions that 'wraps' such loops. I was curious about this idea and searched for nice code examples. Here is my short list of usage of algorithms from the C++ std library that might help in writing better code.

Of course. I could not skip two prominent examples from the original "C++ Seasoning" talk: slide and gather...

Valgrind is *NOT* a leak checker -- Mark Isaacson

A discussion on Valgrind's capacity to detect undefined behavior:

Valgrind is *NOT* a leak checker

by Mark Isaacson

From the article:

Valgrind is one of the most misunderstood tools I know of in my community. Valgrind is not a leak checker. It has a leak checking tool. I'd argue that this tool happens to be the least useful component.

Without changing the way you invoke Valgrind, you get so much more useful information than most people realize. Valgrind finds latent bugs even when they don't cause your program to fail/crash; it doesn't just tell you where the bug happened, it tells you why it happened, in English. Valgrind is an undefined behavior checking tool first, a function and memory profiler second, a data-race detection tool third, and a leak checking tool last...

A Slice of Python in C++ -- Eric Niebler

eric-niebler-toronto.PNGSpeaking of Python-C++ convergence:

A Slice of Python in C++

by Eric Niebler

From the article:

This post describes a fun piece of hackery that went into my Range-v3 library recently: a Python-like range slicing facility with cute, short syntax. It’s nothing earth-shattering from a functionality point of view, but it’s a fun little case study in library design, and it nicely illustrates my philosophy of library design...

ccache 3.2 released

Version 3.2 of ccache was recently released. It can help you be more productive as "It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again" (from the official page). The new version that has been released is a feature version which means lots of goodies and new features.

ccache 3.2 released

From the announcement:

  • Added support for configuring ccache via one or several configuration files instead of via environment variables. Environment variables still have priority but are no longer the recommended way of customizing ccache behavior. See the manual for more information.
  • Added support for compiler error/warning messages with color.
  • Made creation of temporary directories and cache directories smarter to avoid unnecessary stat calls.
  • Improved efficiency of the algorithm that scans for __DATE__ and __TIME__ tokens in the hashed source code.
  • Added support for several binaries (separated by space) in CCACHE_PREFIX.
  • The -c option is no longer passed to the preprocessor. This fixes problems with clang and Solaris’s C++ compiler.
  • ccache no longer passes preprocessor options like -D and -I to the compiler when compiling preprocessed output. This fixes warnings emitted by clang.

And much more ...

 

Quick Q: Is constexpr more constant than const? -- StackOverflow

This week on SO:

Is a constexpr more “constant” than const?

The C++ Programming Language Fourth Edition - Bjarne Stroustrup: (emphasis mine)

2.2.3. Constants

In a few places, constant expressions are required by language rules (e.g., array bounds (§2.2.5, §7.3), case labels (§2.2.4, §9.4.2), some template arguments (§25.2), and constants declared using constexpr). In other cases, compile-time evaluation is important for performance. Independently of performance issues, the notion of immutability (of an object with an unchangeable state) is an important design concern (§10.4).

It seems that Stroustrup is suggesting here that constexpr ensures immutability of an object better than a traditional const declaration. Is this correct? Are there ways in which constexpr can be more secure/less volatile than const, or does Stroustrup simply mean that since there are ways to use constexpr that are not supported with const (see Is constexpr really needed?), in those cases immutability can be ensured using constexpr?

 

Memory management of C libraries in C++ -- Kevin Dungs

In the "better C than C" department:

Memory management of C libraries in C++

by Kevin Dungs

From the article:

Today I had some time to play around with libgit2, an excellent C-library for Git. But since I was thinking about using it together with the freshly released Proxygen, the fast HTTP-framework from Facebook, I wanted to use the library functions from C++ from the start.

This was a perfect opportunity to play around with C++ memory management objects in the context of a C-library...

Overload 124 is now available

overload-124.PNGOverload 124 is now available. It contains the following C++-related articles, and more:

 

Overload 124

Designing Observers in C++11

The observer pattern is over two decades old. Alan Griffiths fits a venerable design pattern into a contemporary context.

Order Notation in Practice

What does complexity measurement mean? Roger Orr reminds us of the academic definition and looks at some real life situations... std::sort is faster than qsort which can come as a surprise to those who assume C is always faster than C++.