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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:27:20+00:00 2026-05-14T21:27:20+00:00

I need to do an assertion based on two related macro preprocessor #define ‘s

  • 0

I need to do an assertion based on two related macro preprocessor #define‘s declared in different header files… The codebase is huge and it would be nice if I could find a place to put the assertion where the two headers are already included, to avoid polluting namespaces unnecessarily.

Checking just that a file includes both explicitly might not suffice, as one (or both) of them might be included in an upper level of a nesting include’s hierarchy.

I know it wouldn’t be too hard to write an script to check that, but if there’s already a tool that does the job, the better.

Example:

file foo.h

#define FOO 0xf

file bar.h

#define BAR 0x1e

I need to put somewhere (it doesn’t matter a lot where) something like this:

#if (2*FOO) != BAR
    #error "foo is not twice bar"
#endif

Yes, I know the example is silly, as they could be replaced so one is derived from the other, but let’s say that the includes can be generated from different places not under my control and I just need to check that they match at compile time… And I don’t want to just add one include after the other, as it might conflict with previous code that I haven’t written, so that’s why I would like to find a file where both are already present.

In brief: how can I find a file that includes (direct or indirectly) two other files?

  • 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-14T21:27:21+00:00Added an answer on May 14, 2026 at 9:27 pm

    As you have both of your includes probably protected by #define guards, you might check in each of those two header files if the other one is included based on #ifdef THE_OTHER_GUARD_NAME, and issue warning (or error, whichever you prefer) if you detected it is included.

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

Sidebar

Ask A Question

Stats

  • Questions 423k
  • Answers 423k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you are referring to two different usages of… May 15, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer I assume you want to know the number of different… May 15, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer Write a custom stream manipulator that stores a reference to… May 15, 2026 at 11:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.