简体   繁体   English

FLT_MAX宏在哪里定义?

[英]Where is the FLT_MAX macro defined?

I tried looking at the float.h header file and all I found was 我尝试查看float.h头文件,发现的全部是

#  define FLT32_MAX FLT_MAX

However, shouldn't it be 但是,不是吗

#  define FLT_MAX (some number)

but I can't find this kind of definition and so I wonder where would the defintion of the FLT_MAX macro be? 但是我找不到这种定义,所以我想知道FLT_MAX宏的定义在哪里?

In C, the macro FLT_MAX is defined in the standard header <float.h> . 在C语言中,宏FLT_MAX在标准头文件<float.h>定义。

Examining a file named float.h on your system and not finding a definition of FLT_MAX doesn't prove anything. 在系统上检查名为float.h的文件,但未找到FLT_MAX的定义不会证明任何事情。 You might be looking at the wrong file. 您可能正在查看错误的文件。 Conceivably <float.h> might not even be a file. 可以想象<float.h>甚至可能不是文件。

This program: 该程序:

#include <stdio.h>
#include <float.h>
int main(void) {
    printf("FLT_MAX = %g\n", FLT_MAX);
}

should compile and run without error. 应该编译并正确运行。 If it doesn't, your system is broken somehow. 如果不是,则您的系统以某种方式损坏。 If it does, you may be able to coax your compiler to tell you where it found <float.h> . 如果是这样,您也许可以哄您的编译器告诉您<float.h> For example, if you're using gcc on a UNIX-like system: 例如,如果您在类似UNIX的系统上使用gcc:

gcc -E filename.c | grep 'float\\.h' gcc -E filename.c | grep 'float\\.h' | grep 'float\\.h'

The <float.h> header should not define a macro named FLT32_MAX , at least not in conforming mode. 所述<float.h>报头应该定义名为宏FLT32_MAX ,至少不会在符合模式。 That's non-standard and it's in the user name space, so a program should be able to use that name for its own purposes. 这是非标准的,位于用户名空间中,因此程序应该能够出于自己的目的使用该名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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