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 3338264

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:21:18+00:00 2026-05-18T00:21:18+00:00

Well here I am sitting down for the millionth time telling myself I’m going

  • 0

Well here I am sitting down for the millionth time telling myself “I’m going to write a game using SDL and C++” except this time I told myself I was going to write it in C. This is because SDL itself is written in C and it seems to just make sense to me. The game that I’m writing will be a simple “SHMUP” (Shoot ’em up) and it will probably be very short code-wise, so I’m wondering are a couple global variables bad? (like “struct base basevar;” or “int SCREEN_W” or something)?

  • 0 0 Answers
  • 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-18T00:21:18+00:00Added an answer on May 18, 2026 at 12:21 am

    Global variables aren’t inherently “bad”. However, they can easily lead to very bad code (in the sense of readability, testability, maintainability) if used carelessly. They can also lead to pernicious multi-threading issues (if you’re using threads), again, if used carelessly.

    Some people have a blanket rule that you should never use them. IMHO, this is too draconian, and if followed religiously, can lead to people passing around a pointer to a big everything_t to all functions, which isn’t a great deal better (although even this simple approach makes your code re-entrant). However, please don’t read this as advocation for “just go wild with globals!”. They are the right answer only in a few situations.

    In your example, it sounds like you have a bunch of settings/parameters that don’t really change. Consider at least grouping them into a settings struct; this gives you the flexibility later to have e.g. a const settings *getSettings() function.

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

Sidebar

Related Questions

Upgrading my project I'm thinking here about transactions. Well, the thing is I'm not
I'm having a problem setting my Session back to Login. Here is my code:
Folks, Here's what I am trying to do: my script will be running as
Bit of an open-ended question here, so I'll outline the problem first. We have
I have an XSD, here is part of it defined below, but it's not
I have tested this in Google Chrome, IE, as well as Firefox and I
I'm trying to get rid of the margins of maps generated using the 'maps'
I have been struggling in getting Start Tls to work for my ldap server.
I've been working through some objective-c/ iOS dev books and I've hit a stumbling
In my UITableViewCells I am displaying text of varying lengths. To accomodate larger amounts

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.