Skip to content

fix: replace C-style casts to compile with -Wold-style-cast -Werror#447

Open
ctonneslan wants to merge 1 commit intocameron314:masterfrom
ctonneslan:fix/replace-c-style-casts
Open

fix: replace C-style casts to compile with -Wold-style-cast -Werror#447
ctonneslan wants to merge 1 commit intocameron314:masterfrom
ctonneslan:fix/replace-c-style-casts

Conversation

@ctonneslan
Copy link

Summary

Replaces C-style casts with static_cast/reinterpret_cast to allow compilation with strict warning flags (-Wold-style-cast -Werror) on GCC 14/15 and Clang 17/18 with C++17/20/23.

Problem

Projects using strict -Wold-style-cast -Werror flags cannot include the library headers without compilation errors:

lightweightsemaphore.h:237: error: use of old-style cast [-Werror=old-style-cast]
lightweightsemaphore.h:238: error: use of old-style cast [-Werror=old-style-cast]
blockingconcurrentqueue.h:59: error: use of old-style cast [-Werror=old-style-cast]

Changes

lightweightsemaphore.h:

  • (time_t)(usecs / ...)static_cast<time_t>(...)
  • (long)(usecs % ...)static_cast<long>(...)
  • (int)toReleasestatic_cast<int>(toRelease)

blockingconcurrentqueue.h:

  • (int)Traits::MAX_SEMA_SPINSstatic_cast<int>(...)
  • (BlockingConcurrentQueue*)1reinterpret_cast<BlockingConcurrentQueue*>(1)

Fixes #444

Replace C-style casts that break compilation with -Wold-style-cast
-Werror on GCC 14/15 and Clang 17/18 with C++17/20/23.

Files changed:
- lightweightsemaphore.h: (time_t), (long), (int) -> static_cast
- blockingconcurrentqueue.h: (int), (BlockingConcurrentQueue*) ->
  static_cast/reinterpret_cast

Fixes cameron314#444
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.

C-style casts break compilation with -Wold-style-cast -Werror (GCC 14/15, C++23)

1 participant