Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:42:02+00:00 2026-05-26T10:42:02+00:00

I am working on a project that uses select from C++ code. The code

  • 0

I am working on a project that uses select from C++ code. The code uses the macros FD_ZERO, FD_SET, FD_ISSET etc. Unfortunately These macros use ‘C’ casts, ergo they generate compiler warnings when the code is compiled with -Wold-style-cast. What is the best way for disabling -Wold-style-cast just for these macros?

The only options I can think of are:

  1. Use #pragma diagnostic to disable the warning for the functions using macros
  2. wrap the macro calls in an inline function and disable the warning around the function.

Does anyone have a better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:42:03+00:00Added an answer on May 26, 2026 at 10:42 am

    I use select and those macros in C++ code with -Wall and get no warnings, though I do not use -Wold-style-cast. I think a better approach would be to take a step back and reconsider why it is important to not use C-style casts. I think, for interfacing with C standard library functions, it is entirely appropriate.

    The C++ dynamic_cast method is useful for polymorphism and classes. const_cast is a special case for removing const-ness. static_cast and C’s (type) casts are very similar. I am not sure what advantage using static_cast<type> provides over (type) casts, except that it is in the C++ style. reinterpret_cast<type> offers little advantage over C’s *(type*)& cast method, and is about as ugly as they come.

    In general, the need for casting implies a certain weakness in the design of software, though dynamic_cast is arguably an exception to this. While it is commendable to strive to not need casts in one’s own code, I don’t think there is much value in trying to retroactively apply these values to third-party libraries, especially standard or OS ones.

    If you really don’t want to use C-style casts in your code, I would set a policy outside of the compiler settings and just review your code and remove them. If you really want to have the compiler do this work for you, then you’ll have to disable the warning for software you can’t control. This may be more work than it is worth, and in some cases is not even necessary. On Darwin, for instance, FD_ISSET has no casts in its implementation. There are, after all, far worse practices than C-style casts to banish from code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use Subversion locally, and we're working on a project that uses a fork
I'm working on a source-code visualization project that uses the Processing core library. The
We're working on a project that uses Velocity for its display templates. Unfortunately, there
I have a project that I'm working that uses XSLT to display data from
I am working in a PHP project that uses checkstyle to validate the code.
I am working on a project that uses the asp.net ajax control toolkit and
I'm working on a project that uses an MDI application with a navigation panel
I am working on a project that uses a queue that keeps information about
I'm working on a project that uses several languages: SQL for querying a database
I'm working on a project that uses the new CSS3 transform:rotate(180deg) feature. Every modern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.