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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:16:48+00:00 2026-05-28T06:16:48+00:00

I am working on a game that is coded in C++ and I would

  • 0

I am working on a game that is coded in C++ and I would like to make it possible to change language at runtime. Currently, the language is chosen at compile time by including a header file (which has language definitions), like so:

#include "lan_eng.h"

Therefore, the game does not allow the language to be changed once the client has been compiled. My question is if there is a way in which I can include files conditionally at runtime? I am new to C++, so at first I was thinking that I could do something like this:

#define DEF_LANGUAGE_ENG
//#define DEF_LANGUAGE_DEN

#ifdef DEF_LANGUAGE_ENG

    #include "lan_eng.h"

#endif

#ifdef DEF_LANGUAGE_DEN

    #include "lan_den.h"

#endif

Sure that makes it easier to maintain, but the problem is that I believe it only works at compile time. I would like to be able to store the chosen language in a variable (which is changed at runtime) and then use that variable to choose which header file to include. Is there a way to do this with header files, or would I be forced to make a class?

I hope it is not a stupid question; my searches did not give me the results I was hoping for.

Thanks in advance!

  • 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-28T06:16:49+00:00Added an answer on May 28, 2026 at 6:16 am

    You can not change #include’s at runtime due to them being evaluated during compile time only.

    What you can do instead, is have “language sheets”. You can build a system that you reference during runtime, or you can have several text documents (such as .xml files) that you read and store when you want to change languages. Doing it this way also allows your application to be extended upon by users of the software in the future, as it will not be hardcoded.

    If you design it in such a way, you could keep all your “language sheets” in one folder, then have your program check that folder for all available language sheets. This will allow users to also add languages to your program.

    What you will basically need to do is create a string table, which can be done as part of a hardcoded method, or as part of a more dynamic method (mentioned as the language sheets).

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

Sidebar

Related Questions

I'm working on a game (C#) that uses a Robocode-like programming model: participants inherit
I am working on a web application (ASP.NET) game that would consist of a
I'm practicing writing MVC applications. I have a Mastermind game, that I would like
Working on a game project that involves a scripting language that I want to
I am developing a 3d shooter game that I would like to run on
Alright so here is my issue. I'm working a game engine that will eventually
I'm working on an iPhone game that takes place on the ocean surface. Can
I am working on a little card-swapping world-travel game that I sort of envision
I'm working on an isometric game for fast browsers that support <canvas> , which
I'm working on a small roguelike game, and for any object/thing that is not

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.