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

Use standard/built-in types instead of local typedefs where possible #126

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mikedld
Copy link
Contributor

@mikedld mikedld commented Sep 13, 2020

This PR removes most of manually defined types in utp_types.h in favor of either standard integral types defined as part of C99, or built-in basic types, which reduces the chances of clashes with other code since the names were quite generic/common. All the changes here are done with dull find/replace, please do tell if there're any formatting issues or whatnot that you'd like me to fix.

Fixes: #122
Overlaps with: #70

Since stdint.h was added in C99, pass the required C standard to the
compiler explicitly, and do the same for C++ standard along the way.
As we're using std int types (since previous commit), use corresponding std
format macros to avoid potential format specifier mismatches.
MSDN states that SSIZE_T is defined as LONG_PTR, and LONG_PTR is defined as
long (32-bit) when building for x86 and __int64 (64-bit) when building for
x64, which basically means that it's signed and its size matches that of a
pointer, which in turn is the definition of intptr_t. The latter is
provided by stdint.h which we're already including.
This avoids potential clashes as the name is way too common.
This avoids potential clashes as the name is way too common.
This avoids potential clashes as the name is way too common.
This avoids potential clashes as the name is way too common.
This header is C99 and we can use it since we're already using stdint.h and
inttypes.h anyway. It also helps to avoid clashes when other code that uses
this library includes stdbool.h.
@mikedld
Copy link
Contributor Author

mikedld commented Sep 13, 2020

I'm adding -std=c99 and defining _POSIX_C_SOURCE here so that it builds on Linux, but it also builds with -std=gnu99 without defining _POSIX_C_SOURCE (again, on Linux). If you prefer the latter (I honestly didn't check on other platforms like *BSD) we could do that, but I'd rather keep -std=c99 (maybe adding some more definitions for other platforms) if possible.

Most probably not all the places were covered, some more work (unrelated to
these changes) needs to be done.
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

Successfully merging this pull request may close these issues.

Unable to build on Haiku
1 participant