units icon indicating copy to clipboard operation
units copied to clipboard

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

Open GElliott opened this issue 7 years ago • 3 comments

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 avatar Oct 10 '18 00:10 GElliott

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

GElliott avatar Oct 10 '18 16:10 GElliott

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.

nholthaus avatar Oct 26 '18 19:10 nholthaus

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.

JohelEGP avatar Oct 26 '18 20:10 JohelEGP