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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:21:41+00:00 2026-05-23T08:21:41+00:00

I have a header with a particular set of rules that the user must

  • 0

I have a header with a particular set of rules that the user must follow. If the user does not want to follow the rules, they must define a preprocessor macro which will disable the checks. If the user is using the library, the user must include the header in every one of their classes that uses any code from the library or explicitly state otherwise by the above mentioned preprocessor (in this case, the header may be included implicitly [using one of the library’s classes] which is fine):

// User using my library, they must include the BaseHeader.h or otherwise use the following define
// #define NOT_USING_BASE_HEADER //(can of course be defined project wide)
#include <BaseHeader.h>
// ... other includes (not necessarily from my library)
class Foo
{
  //...
};

Is there a way to accomplish this? Keep in mind that the base header is also being included

  • 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-23T08:21:42+00:00Added an answer on May 23, 2026 at 8:21 am

    I’m not sure if I understand your question entirely, but do you think this will help?

    BaseHeader.h:

    
    #pragma once
    #define BASE_HEADER_INCLUDED
    ...
    

    internal_header.h:

    
    #pragma once
    
    #ifdef NOT_USING_BASE_HEADER
       #ifdef BASE_HEADER_INCLUDED
          #error You can't both define NOT_USING_BASE_HEADER and include the base-header-file.
       #endif
       ... 
    #elseif defined BASE_HEADER_INCLUDED
       ...
    #else
       #error You have to either define NOT_USING_BASE_HEADER or include the base header file!
    #endif
    

    If you want to make it so that it doesn’t take “internal” includes of the baseheader.h, then you have to add/remove a define to make sure that it doesn’t define it:

    internal_header.h:

    
    #pragma once
    
    #define SKIP_HEADER_DEFINE
    #include 
    #undef SKIP_HEADER_DEFINE
    

    And in BaseHeader.h:

    
    #pragma once
    #ifndef SKIP_HEADER_DEFINE
       #define BASE_HEADER_INCLUDED
    #endif
    

    Cheers,
    Simon

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

Sidebar

Related Questions

I have a header menu and try to define different CSS classes for each
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have a header file, lets say Common.h, that is included in all of
Assume I have 2 controllers that handle 2 parts of the page - header
I have a code to downolad a particular file that is stored at a
Is it possible to manipulate the placeholders so that I can not only set
I have a variable ( $output ) that is set to a string. To
I have a variable ( $output ) that is set to a string. To
Stuck with this particular issue. I have code that get lots of pages from
I have one particular request in my app that requires Basic authentication, so I

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.