简体   繁体   中英

Way to declare float compile-time constant in C

I know that I can declare a named compile-time constant in C for integers by using enums, but is there a way to declare named compile-time constants in C for floats as well, without using macros (I know that C++ has constexpr, but I am strictly using C right now)? Answers containing compiler-specific C-language extensions are also greatly appreciated.

Use array of const float. Which will produce constant data of type float. const float *arr[3] = {11.21,21.31,31.23}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM