Commit fc72d3b3 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'cosmetics' into 'master'

Make sure there is always a non-empty compiler name or compiler version

This fixes a bug reported by Heinrich. When the compiler string is empty, the HDF5 i/o fails as you cannot write an empty string as an attribute. 
This fix makes sure the compiler name and version is always a non-empty string.

See merge request !44
parents 87dfe4d8 940c41c5
......@@ -20,6 +20,7 @@
/* Some standard headers. */
#include <stdio.h>
#include <string.h>
/* This object's header. */
#include "version.h"
......@@ -68,22 +69,22 @@ const char *package_description(void) {
const char *compiler_name(void) {
static char compiler[256] = {0};
#if defined(__INTEL_COMPILER)
static const char *compiler = "ICC";
sprintf(compiler, "ICC");
#elif defined(__clang__)
static const char *compiler = "LLVM/Clang";
sprintf(compiler, "LLVM/Clang");
#elif defined(__xlc__)
static const char *compiler = "IBM XL";
sprintf(compiler, "IBM XL");
#elif defined(__GNUC__)
static const char *compiler = "GCC";
static const char *compiler = "Unknown Compiler";
sprintf(compiler, "GCC");
if (strlen(compiler) == 0) sprintf(compiler, "Unknown compiler");
return compiler;
const char *compiler_version(void) {
static char version[256];
static char version[256] = {0};
#if defined(__INTEL_COMPILER)
const int major = __INTEL_COMPILER / 100;
const int minor = __INTEL_COMPILER - major * 100;
......@@ -98,9 +99,8 @@ const char *compiler_version(void) {
sprintf(version, "%i.%i.%i", major, minor, patch);
#elif defined(__GNUC__)
sprintf(version, "%i.%i.%i", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
sprintf(version, "---");
if (strlen(version) == 0) sprintf(version, "Unknown version");
return version;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment