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

  • Home
  • SEARCH
  • 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 7167655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:37:13+00:00 2026-05-28T14:37:13+00:00

I have an opensource lib in .c, it has 2 parameters, but they are

  • 0

I have an opensource lib in .c, it has 2 parameters, but they are hardcoded in .h file with #define. They are around all code.
Change the parameter-> recompile.
How can I do best design of my cpp wrapper to this to which I can pass some parameter values and will have ability to call code without recompiling it?

  • 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-28T14:37:15+00:00Added an answer on May 28, 2026 at 2:37 pm

    You can make them static members of a class and initialize them in an implementation file.

    //header.h
    class Hardcoded
    {
    public:
       static int param;
    };
    
    //implementation.cpp
    #include "header.h"
    int Hardcoded::param = 0;
    

    or you could declare a free variable with extern which you initialize in an implementation file.

    EDIT:

    You can continue using macros if you don’t want to change the whole code, without requiring compilation every time you want to change the value:

    #define PARAM Hardcoded::param
    

    EDIT:

    I now see what you mean:

    #if QLZ_COMPRESSION_LEVEL == 1
            state->hash[i].offset = 0;
    #else
            state->hash_counter[i] = 0;
    #endif
    

    In this case, it’s impossible to do what you want, and you shouldn’t do it anyway, because you need to compile a different thing every time the define changes. So it’s not a matter of re-compiling, it’s a matter that you need to recompile.

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

Sidebar

Related Questions

i have this opensource code which is used to echo back response to web-socket
Suppose, I have an opensource project that depends on some library, that must be
I have a stable opensource library and was wondering how (and if) I can
Does anyone have instructions on building the opensource version of Qt? Now that the
I have an open source'd website. Some content is private such as connection parameters,
I have written a lib that I am about to publish open source. It
After delving into the world of opensource I have found implementation is emphasised over
I am working on opensource project. As of of now I don't have any
So jenerally I have small C++ project based on OpenSource crossplatform libs. So it
I have this small code library that I'm considering releasing into Open Source. 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.