1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// Copyright (c) 2017-2023, University of Tennessee. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// This program is free software: you can redistribute it and/or modify it under
// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
#ifdef __cplusplus
#include <iostream>
#else
#include <stdio.h>
#endif
int main()
{
// xlc must come before clang
// clang and icc must come before gcc
// icpx and icx must come before clang
const char* compiler =
#ifdef __cplusplus
// IBM's documentation says __IBMCPP__,
// but xlc -qshowmacros shows __ibmxl_version__.
#if defined(__IBMCPP__) || defined(__ibmxl_version__)
"xlc++";
#elif defined(_CRAYC)
"cray";
#elif defined(__ICC)
"icpc";
#elif defined(__INTEL_LLVM_COMPILER)
"icpx";
#elif defined(_MSC_VER)
"MSC";
#elif defined(__clang__)
"clang++";
#elif defined(__GNUG__)
"g++";
#else
"unknown C++";
#endif
#else
#if defined(__IBMC__) || defined(__ibmxl_version__)
"xlc";
#elif defined(_CRAYC)
"cray";
#elif defined(__ICC)
"icc";
#elif defined(__INTEL_LLVM_COMPILER)
"icx";
#elif defined(_MSC_VER)
"MSC";
#elif defined(__clang__)
"clang";
#elif defined(__GNUC__)
"gcc";
#else
"unknown C";
#endif
#endif
#ifdef __cplusplus
std::cout << compiler << "\n";
#else
printf( "%s\n", compiler );
#endif
return 0;
}
|