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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:28:38+00:00 2026-06-09T08:28:38+00:00

Our code has versioning information hardcoded in printf in at least 20 different files

  • 0

Our code has versioning information hardcoded in printf in at least 20 different files like:
printf("Software version v11.2"); This means changing 20 files everytime there is an update.

Instead i wish to use a macro and #include it in a common.h file, such that version update is just changing one macro, that’s all.

I tried something like:

#include <stdio.h>
#define VERSION "v11.2"
int main()
{
  printf("Trying to print macro: ", VERSION);
}

But this style of “string””string” works in Java not in C.
Any ideas how to accomplish it?

We will use the gcc for compilation.

NOTE: The macro is also used in some typical *.rc files, where we can’t use a variable, and somewhere these rc files are parsed using SQL query. So we can’t use variables like char ver[]=”v11.2″

  • 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-09T08:28:44+00:00Added an answer on June 9, 2026 at 8:28 am

    Here are two possible solutions.

    #include <stdio.h>
    #define VERSION "v11.2"
    int main()
    {
      // Let printf insert the string when doing the output.
      printf("Trying to print macro: %s\n", VERSION);
      // Let the compiler concatenate the strings.
      puts("Trying to print macro: " VERSION);
      // Let the compiler concatenate the strings, can be assigned to a variable.
      const char buf[] = "Trying to print macro: " VERSION;
      puts(buf);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our code has something like this: @Resource(name = java:comp/resource/foo/bar/ONE_QUEUE) private Queue queue; However, in
Our code has to run on both SLES9 (old) and an even older version
I have recently become aware that our code has several implementations of a version
The code has a runtime dependency which is not available in our development environment
In our code we have quite a few cases of this pattern: class outerClass
This is our code: <div> <table style=width: 349px> <tr> <td class=style1> <asp:ListBox ID=leftbox runat=server
Our code base has a few decorators that are used extensively. When I create
Since a BSTR is only a typedef for wchar_t* our code base has several
Our code uses different settings for development and production environments so we were looking
The following (simplified version of our) code passes our JUnit tests under Hibernate, but

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.