Skip to content

MSVC complains about POSIX calls to special math functions e.g. j0 #839

Description

@jhale

Claude:

No — _j0 is the opposite problem. The underscore-prefixed names are Microsoft's CRT-specific names; glibc, musl, macOS's libm, and the BSDs don't provide _j0 at all, so your Linux/macOS builds would fail to link.

The standard approach is a small compatibility shim:

#include <math.h>

#if defined(_MSC_VER)
  #define BESSEL_J0(x) _j0(x)
  #define BESSEL_Y0(x) _y0(x)
  #define BESSEL_JN(n, x) _jn((n), (x))
  #define BESSEL_YN(n, x) _yn((n), (x))
#else
  #define BESSEL_J0(x) j0(x)
  #define BESSEL_Y0(x) y0(x)
  #define BESSEL_JN(n, x) jn((n), (x))
  #define BESSEL_YN(n, x) yn((n), (x))
#endif

Not a very nice fix...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions