https://issues.dlang.org/show_bug.cgi?id=23411

          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: nob...@puremagic.com
          Reporter: dave287...@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:
#  define NAN (__builtin_nanf (""))


So the above file preprocesses to:

float x = __builtin_nanf("0x7fc00000");

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

--

Reply via email to