www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23411] New: ImportC: undefined identifier __builtin_nanf


          Issue ID: 23411
           Summary: ImportC: undefined identifier __builtin_nanf
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

The following C file fails to compile

#include <math.h>

float x = NAN; //  Error: undefined identifier `__builtin_nanf`, did you mean
template `__builtin_inf()()`?

On macOS, the standard C macro NAN is defined as:
#define NAN __builtin_nanf("0x7fc00000")

On x64 linux, it is defined as:

So the above file preprocesses to:

float x = __builtin_nanf("0x7fc00000");

Looking at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html, there’s
__builtin_nan and __builtin_nanl.

Oct 13 2022