Product News

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++.

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 ...

 

C++ STL for Embedded Developers--John Hinke

E.S.R. Labs presents its STL library adapted to embedded environments and discusses some of the choices they made for it:

C++ STL for Embedded Developers

by John Hinke

From the article:

C++ embedded programming is very difficult. There are some limitations that are not always present in traditional programming environments such as limited memory, slower processors, and older C++ compilers.

We have developed a set of best-practice processes and frameworks to support writing high-quality embedded applications...

Valgrind 3.10.1 released

Valgrind, a useful tool for any C++ developer released a new version today:

Valgrind 3.10.1 released

From the announcement:

3.10.1 is a bug fix release. It fixes various bugs reported in 3.10.0 and backports fixes for all reported missing AArch64 ARMv8 instructions and syscalls from the trunk. If you package or deliver 3.10.0 for others to use, you might want to consider upgrading to 3.10.1 instead.

Sneak Preview of C++17 -- Gabriel Ha

A preview what is going into C++17 after the recent Standards Committee meeting. 

GoingNative 32: Sneak Preview of C++17

By Gabriel Ha

From the article: 

Join us with ISO Committee member (and Microsoft as well, of course =P) Gabriel Dos Reis, who graciously took the time to give us the inside scoop of some things that made it into C++17, as well as things that got taken out. All this is fresh off the press of the most recent C++ Standards Meeting...

 

 

New optimizations for X86 in upcoming GCC 5.0 -- Evgeny Stupachenko

Fresh on the Intel Developer Zone blog:

New optimizations for X86 in upcoming GCC 5.0

by Evgeny Stupachenko

From the article:

Part 1. Vectorization of loads/stores group.

GCC 5.0 significantly improves vector code quality for load groups and store groups. By loads/stores group I mean iterated consecutive sequence of loads/stores. For example:

x = a[i], y = a[i + 1], z = a[i + 2] iterated by “i” is loads group of size 3

...

The most frequent case where loads/stores groups are applicable is array of structures.
  1. Image conversion (RGB structure to some other) ...
  2. N-dimentional coordinates. (Normalize array of XYZ points) ...
  3. Multiplication of vectors by constant matrix: ...

... GCC 5.0:

  1. Introduces vectorization of load/store groups of size 3
  2. Improves load groups vectorization for all supported sizes
  3. Maximizes load/store groups performance by generating code that is more optimal for particular x86 CPU...

 

Facebook Flint: Public domain C++ lint

Some months ago Facebook brought their C/C++ Facebook-Lint (Flint) analyzer into public domain and made it available on github.com/facebook/flint. Flint provides a lint framework and a number of C++11/14 style rules that we have found useful in our company.

This static code analyzer is not based on a C++ parser, but works with a tokenizer, completely written in D. (The previous C++ version of the program is still part of the repository.) 

Andrei Alexandescu gives detailed information in his blog entry:

Under the Hood: Building and open-sourcing flint

by Andrei Alexandrescu

... Writing a C++ linter in particular is not for the faint of heart because of C++'s high barrier to entry for parsing. That said, there are now dozens of C++ lint programs with a variety of features, some open sourced. So the natural question is why we chose to write our own instead of using a pre-existing one.

When we started this project, the lint programs we tried were too slow and most didn't support the C++11 features that our codebase had already started to use. Clang, which today would be logical starting point for a C++ analysis tool, offered too little support back then...

The distributed makefile is designed to work on Mac OS and Linux. But it is pretty easy to build a working flint.exe for Windows with Visual Studio and an installed D compiler and the corresponding plugin.

We prefer in our company either pairing or code reviews to ensure a high code quality. But we decided to use Flint as an additional safety-net and since the speed of the analyzer is so amazingly high, we were able to integrate it into the pre-commit hook of our Mercurial repository without any noticable performance drawbacks. So all to be committed C++ files are checked against a subset of all rules, that Flint supports.

(We disabled some Flint rules in the source code, because of missing C++11 capabilities of Visual Studio 2012/2013 and certain checks that does not make sence in our context.)

Consider automatically applying a lint tool in your project build. Whether you pick this or another one, it's worth checking out.

Poco C++ Library release version 1.4.7p1

POCO Development Release 1.4.7p1 Available

This release fixes a few issues in 1.4.7 and earlier releases. Most important, the Visual C++ project files for Visual C++ 2010 and later have optimization enabled in release builds. Previous builds had optimization disabled due to a bug in Visual Studio when upgrading 2008 project files with custom optimization settings.

There’s a new feature as well – HTTPClientSession now supports a global proxy setting, which will be used by all instances of HTTP(S)ClientSession, including HTTP(S)StreamOpener.

Detailed information is available in the CHANGELOG.

Free CppCat for Students

CppCat is a static code analyzer integrating into the Visual Studio 2010-2013 environment. The analyzer is designed for regular use and allows detecting a large number of various errors and typos in programs written in C and C++. For the purpose of popularizing it, we've decided to launch a student-support program granting free licenses to every higher school student who will contact and ask us about that. You just need to send us a photo of your student card or transcript.

A few words about static code analysis

Static code analysis tools draw the programmer's attention to those fragments which are very likely to contain errors. Here's a simple example:

double var_z;

....

var_z = ( var_z - 16 / 116 ) / 7.787;

This code is correct from the viewpoint of the language and compiler. It's just a regular situation when division of the integer number 16 by integer number 116 results in 0. Expressions like that are necessary sometimes. However, the analyzer takes a wider perspective of the code and detects an error pattern: if the result of such an integer division is then used together with the double type, it may signal something is wrong.

The analyzer will draw your attention to this suspicious division with the following warning: V636 The '16 / 116' expression was implicitly casted from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. color.c 125

The code was most likely meant to look as follows:

var_z = ( var_z - 16.0 / 116.0 ) / 7.787;

The division now results in 0,137931 instead of 0.

Static analysis tools can be treated as an extension to compiler warnings. Unlike the compiler, analyzers deal with higher-level constructs and rely on empirical methods trying to guess if the code works the way the programmer wanted it to.

A few words about the CppCat analyzer

CppCat is a static code analyzer which is easy to set and use. It is an excellent tool to get started with the static analysis methodology. It is not as powerful as its big brother PVS-Studio (see their comparison), but it is more than sufficient for most tasks. In any case, CppCat's functionality is surely quite enough for students and single developers.

The analyzer can integrate into Visual Studio 2010, 2012, 2013. Unfortunately, it can't integrate into Express editions and we can't help it as Visual Studio Express editions don't support plugins.

The analyzer supports the following languages: C, C++, C++/CLI, C++/CX.

An important feature of the analyzer is an automated analysis of freshly modified code. After compilation of modified files is finished, CppCat starts analyzing the code in background and displays a warning whenever anything suspicious is found. This feature allows programmers to detect errors at the very early development stage and thus save time on bug search and fixes.

You can download CppCat from the product's website: http://www.cppcat.com

How to get a CppCat license

Using CppCat will help you in acquiring skills of working with static analysis tools and improving your qualification. Static analyzers are growing more and more popular nowadays, so it'll be just good if you can specify in your résumé that you know how to use these tools.

To get a license you just need to send to our email [email protected] a photo or scan of your student card, transcript or other document confirming that you are a higher school student. Please specify your first and second name and the name of your university as it might be very difficult to make out this information from the photo. These data will be used to generate your personal registration key.

The license will be valid through 1 year. If you wish to be able to use CppCat after that, you will have to send us a new photo of your student card.

Cevelop Updated for the Eclipse Luna Service Release 1 -- Mirko Stocker

News about Cevelop, a C++ IDE for professional developers from the Institute for Software at HSR Hochschule für Technik:

Cevelop Updated for the Eclipse Luna Service Release 1

by Mirko Stocker

From the announcement:

We have rebased Cevelop on top of the latest Eclipse Luna Service Release SR1. The Eclipse CDT team used the chance to include some new features. For example, code completion can now show default arguments and gives you more information on template parameters... See the CDT 8.5 changelog for a comprehensive list of changes.