24 lines · c
1//===-- Unittests for math constants --------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8#include "include/llvm-libc-macros/math-macros.h"9 10#define IS_DOUBLE(X) _Generic((X), double: 1, default: 0)11 12#define IS_FLOAT(X) _Generic((X), float: 1, default: 0)13 14// check if macro is defined15#ifndef M_PI16#error "M_PI macro is not defined"17#else18int main(void) {19 _Static_assert(IS_DOUBLE(M_PI), "M_PI is not of double type.");20 _Static_assert(IS_FLOAT(M_PIf), "M_PIf is not of float type.");21 return 0;22}23#endif24