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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:54:04+00:00 2026-05-27T18:54:04+00:00

OS: Windows 7, Compiler: GCC 3.2.3 (MinGW) I have created those three data structures

  • 0

OS: Windows 7, Compiler: GCC 3.2.3 (MinGW)

I have created those three data structures in C:

#define MAP_NAME_LEN    30
#define MAP_W           25
#define MAP_H           19
#define WORLD_W         32
#define WORLD_H         32

typedef unsigned char byte;

typedef struct Tile
{
    byte type;
    byte character;
    byte fgColor;
    byte bgColor;
};

typedef struct Map
{
    char name[MAP_NAME_LEN];
    Tile overlay[MAP_H][MAP_W];
    Tile underlay[MAP_H][MAP_W];
};

typedef struct World
{
    Map area[WORLD_H][WORLD_W];
};

When I try to create individual instances of Tile and/or Map, it’s ok, no problem at all, everything works. But then if I try to create a World, like…

int main()
{
    World world;
}

…the program simply crashes (Windows 7 says that the program has crashed and is looking for a solution, etc). Do you guys have any idea why does that happen?

Thanks!

  • 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-27T18:54:05+00:00Added an answer on May 27, 2026 at 6:54 pm

    Depending on the values of MAP_NAME_LEN, MAP_H, MAP_W, WORLD_H, and WORLD_W, you may have created a MASSIVE structure on the stack. Don’t do that. The stack is relatively small, and generally cannot handle allocations of more than a few megabytes total (and often can only handle a few dozen kilobytes of allocation at a time). Given your constant values, you’re likely to be running up against these limits – your World structure is nearly 4MB large, way too big to reasonably put on the stack.

    So, instead, allocate it on the heap with malloc, or as a global or file-local static variable:

    World world;
    
    int main()
    {
        /* ... */
    }
    

    or

    int main()
    {
        World *world = malloc(sizeof(*world));
        /* ... */
        free(world);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I,m using gcc compiler(MinGW) on Windows XP.I created a .dll library libdir.dll than I
I have installed MinGW compiler in Windows 7. GCC version is 4.6.1. I have
I'm having a seemingly silly problem with my gcc compiler. I have installed MinGW
I use GNUStep to compile Objective-C on Windows 7 using GCC and MinGW. I'd
Is there possibility to compile windows service using only mingw c++ compiler and library?
I have MinGW on my windows 7 machine. I wish to install and use
I'm trying to debug a Windows program compiled using MinGW's gcc that only ever
OS: Windows 7 Pro X64 IDE: Eclipse IDE for C/C++ Developers Compiler: MinGW (lastest,
(Running MingW on 64-bit Windows 7 and the GCC on Kubuntu) This may possibly
I am compiling this program on Windows, with gcc (MinGW) and GTK+: #include <gtk/gtk.h>

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.