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 8096195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:22:28+00:00 2026-06-05T21:22:28+00:00

I have a c++ implementation file (my.cpp) that indirectly includes a header file (b.h)

  • 0

I have a c++ implementation file (my.cpp) that indirectly includes a header file (b.h) that defines _MAX_DRIVE:

// b.h
#define _MAX_DRIVE  64

Then my.cpp includes stdlib.h which also defines _MAX_DRIVE

// stdlib.h
#define _MAX_DRIVE  3   /* max. length of drive component */

Obviously this produces a macro-redefinition warning:

stdlib.h(185) : warning C4005: '_MAX_DRIVE' : macro redefinition

My questions are:

  1. How much code is affected by this redefinition, is it just the compilation unit for my.cpp?
  2. Could the redefined value make its way in to other code if my.cpp is part of a static library?
  3. If I never even reference _MAX_DRIVE in my.cpp, is is safe to tell the compiler to ignore this macro redefinition warning?
  • 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-06-05T21:22:30+00:00Added an answer on June 5, 2026 at 9:22 pm
    1. It’s until the end of the current compilation unit, or until the next #undef.
    2. No; macro names are only seen by the preprocessor, which finishes running before compilation even begins.
    3. It doesn’t sound like a very sensible idea. It would be a better idea to avoid having two macros with the same name (especially one that begins with a single underscore followed by a capital letter, as they’re reserved for the implementation).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three files: movie.h (header); movie.cpp (implementation file); lab9.cpp (driver file using movie
I have a C++ class implementation file which has some constants. The constants appear
I have a cpp file with a huge class implementation. Now I have to
I've seen fairly consistent advice that an implementation file (.cc / .cpp) should include
I have a NSDate *date1 in class1 implementation file(I initialized it as Global variable).
I have a .m file, containing a @implementation , but it has gotten too
Given I have two File objects I can think of the following implementation: public
I currently have a program where my main code is in a file main.cpp.
/** @file ListP.cpp * ADT list - Pointer-based implementation. */ #include <iostream> #include <cstddef>
When my cpp file uses #include to add some header, does my final program's

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.