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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:11:01+00:00 2026-06-01T17:11:01+00:00

I started learning openGL and also started splitting my project in multiple source files

  • 0

I started learning openGL and also started splitting my project in multiple source files for the first time too. As such I’m still a bit confused and sometimes I feel my variables are scattered around especially since openGL requires extensive use of global variables. At the moment I got about 15 files.

My major problem is that some variables are for example shared by some modules and some other variables are shared only by a few of those and some other modules. If I put all these variables in a common.h file will there be any problems (performance-wise) since not all variables will be used by all modules?

Using the above method I also have the problem that if I use types defined in other header files I have to include those too. I could also use ‘#if (defined’ macros, but that doesn’t seem the most appropriate method.

  • 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-01T17:11:02+00:00Added an answer on June 1, 2026 at 5:11 pm

    Including extern declarations for unused variables shouldn’t cause performance problems (definitely not at run-time, but it will introduce an imperceptibly small overhead at compile-time).

    It will, however, result in your code being less maintainable. Best practice is to organize your globally-scoped variables and functions into headers based on use or purpose. Things that are conceptually related go in the same header, and things that are unrelated go in different headers. That makes it easier to include the functionality that you need without pulling in massive amounts of junk that you don’t.

    I wouldn’t consider it a problem that you need to include headers in order to pull in datatype definitions. That’s just part of how the C language works. You can make it easier for yourself by ensuring that all of your headers are self-sufficient. That is, if a header uses a particular datatype, that header should include the header where that type is defined. That way, your .c files don’t have to worry about analyzing the header and figuring out what other headers need to be included. Headers that aren’t self-sufficient can also lead to problems where code builds differently (or not at all) depending on the order in which the headers were included.

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

Sidebar

Related Questions

I just started learning opengl and writing a first person shooter but I'm getting
I've just started learning LWJGL (Java OpenGL), and i'm encountering an enormous amount of
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
I'm currently learning OpenGL ES programming on Android (2.1). I started with the obligatory
I've recently started learning OpenGl through the SB fifth edition, unfortunately got stuck right
I need to visualize 3D point clouds using C++, I started learning OpenGL but
I am learning OpenGL and just started getting into lighting. I enable lighting and
I have just started learning OpenGL using the tutorials on Nehe, and so far
I started learning rails a few days ago and I'm reading head first rails
I've been writing programs using OpenGL. Recently, I started learning OpenGL Shading Language. I'm

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.