What new C11 language features will you will get by using the latest XL C/C++ compiler?
rcraik 310000SJR3 Visits (7439)
The latest version of XL C/C++ for little endian Linux distributions is fully C11 compliant! In addition to all of the features supported by V13.1.1, the new version 13.1.2 also supports generic selection expressions, making it possible to overload an expression based on type; and also makes it much simpler to initialise complex floating point numbers via the CMPLX macros. See below for more details:
Complex value initialisations
The C11 standard specifies three new macros for initialising complex numbers:
#include <complex.h> double complex CMPLX(double x, double y);
Each will expand to an expression of the specified complex type with the specified real (x) and imaginary (y) values. For example:
cf will be initialised with a value of 1.0f + i 2.0f
These new C11 macros now provide a way to initialise complex numbers with an imaginary value of infinity or NaN, which was not previously possible in a general way.
For more information see section 188.8.131.52 of the C11 standard.
The generic selection expression provides a mechanism for making a compile-time selection between several different expressions based on the type of a controlling expression. This makes it simple to define type-generic macros, as in the following example:
#define SQRT(X) _Generic((X), \
For each use of this SQRT macro, the type of X will be deduced by the compiler, and this type will be used to select the appropriate function to actually call. So, if the user wrote SQRT(1.1f), the compiler would replace it with a call to sqrtf(1.1f).
For more information see section 184.108.40.206 of the C11 standard.
Why not get hold of the new XL C/C++ V13.1.2 for little endian Linux distributions and give these new features a go!