Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C99 compatibility of bool declaration #90

Closed
ennorehling opened this issue Dec 11, 2016 · 6 comments
Closed

C99 compatibility of bool declaration #90

ennorehling opened this issue Dec 11, 2016 · 6 comments

Comments

@ennorehling
Copy link

In utf8proc.h, true, false and bool are defined. They are reserved keywords in modern C (not just C++), and clash with those definitions.

#  ifndef __cplusplus
typedef unsigned char utf8proc_bool;
enum {false, true};
#  else
typedef bool utf8proc_bool;
#  endif

This breaks compilation on MSVC, and there is no preprocessor macro I can define to let utf8proc.h know that bool is already defined elsewhere. Aside from the C99 standard, it also breaks if the utf8proc.h header is included after one that also defines false and true (like stdbool.h, which can be tested for with the __bool_true_false_are_defined feature macro).

@stevengj
Copy link
Member

It doesn't define bool, but it does define false and true, and you're right that these conflict with stdbool.h in C99.

@stevengj
Copy link
Member

We shouldn't define false and true at all in the public header file, since we only use these internally.

@stevengj
Copy link
Member

stevengj commented Dec 11, 2016

(They are not technically reserved words in C, as I understand it; it should be safe to define them in utf8proc.c, where we don't include stdbool.h for MSVC?)

@stevengj
Copy link
Member

On non-MS compilers, we include stdbool.hin C. We didn't do so on MSVC because MS didn't provide that header...has that been fixed?

@stevengj
Copy link
Member

stevengj commented Dec 11, 2016

Ah, I see that they finally fixed this in 2013: https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/

@stevengj
Copy link
Member

Should be fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants