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

Eliminating Pedantic warnings #65

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Eliminating Pedantic warnings #65

merged 2 commits into from
Feb 24, 2025

Conversation

JG-Adams
Copy link
Contributor

@JG-Adams JG-Adams commented Feb 15, 2025

I am on MinGW GCC 13.2 So with -Wpedantic you'll see a bunch of warning pops up in ENet. It involved the mixing of two separate enums with their | operations. We resolve this by using (int) which should generate absolutely no extra codes and remove the annoying messages.

There was also a mismatch of types in one of the printf when using ENET_DEBUG. So I corrected that at line: 3185-92

Finally the use of ENET_ATOMIC_CAS in enet_get_time() with the implementation of line 1222-28 ISO forbid the use of ({...)} but here where it's implemented it only occurs for GCC which make the expression safe and valid. To ignore such message we would have to use at line: 5101

#if defined(GNUC) // Ignore invalid warning.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
uint64_t old_value = ENET_ATOMIC_CAS(&start_time_ns, 0, want_value);
#if defined(GNUC)
#pragma GCC diagnostic pop
#endif

I am on MinGW GCC 13.2 So with -Wpedantic you'll see a bunch of warning pops up in ENet.
It involved the mixing of two separate enums with their | operations. We resolve this by using (int) which should generate absolutely no extra codes and remove the annoying messages.

There was also a mismatch of types in one of the printf when using ENET_DEBUG. So I corrected that at line: 3185-92

Finally the use of ENET_ATOMIC_CAS in enet_get_time() with the implementation of line 1222-28 ISO forbid the use of ({...)} but here where it's implemented it only occurs for GCC which make the expression safe and valid. To ignore such message we would have to use at line: 5101
#if defined(__GNUC__) // Ignore warning.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
uint64_t old_value = ENET_ATOMIC_CAS(&start_time_ns, 0, want_value);
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
@zpl-zak
Copy link
Member

zpl-zak commented Feb 23, 2025

Thanks for the contrib! Likewise, could you please resolve the conflicts so we can merge it in? Thanks!

@zpl-zak zpl-zak merged commit f7febef into zpl-c:master Feb 24, 2025
7 checks passed
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.

2 participants