nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
947 stars 135 forks source link

Newton UDL suffix conflicts with `ctype.h` macro `_N`. #194

Open GElliott opened 5 years ago

GElliott commented 5 years ago

I've come across some ctype.h implementations that define and leak the macro _N. This conflicts with the UDL for newtons in units.h. Compiler errors result when a user does #include "units.h".

Example: https://github.com/eblot/newlib/blob/master/newlib/libc/include/ctype.h#L35

Although I think this bug deserves to be written against the particular maintainers of ctype.h (e.g., newlib), I wonder if units.h should #undef or #pragma push_macro("_N"). In any case, I thought this conflict should be documented.

I'm using units v2.3.1.

GElliott commented 5 years ago

I've reported the issue to the newlib folks. We'll see what they have to say.

nholthaus commented 5 years ago

our advice has been to let users do the undef'ing (but to document known conflicts). in v3 we've separated the different unit types into different headers, which will reduce the pain for people who don't deal with certain dimensions of units.

JohelEGP commented 5 years ago

I think the problem is fixed in the v3.x branch, which removed the space between the "" of operator"" and the following literal, so operator"" _N ->operator""_N.