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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:18:05+00:00 2026-06-17T04:18:05+00:00

I am using MinGW GCC compiler on Windows 7. I am trying to compile

  • 0

I am using MinGW GCC compiler on Windows 7. I am trying to compile source that contains the following code:

MEMORYSTATUSEX mem_stat;
mem_stat.dwLength = sizeof(memstat);
BOOL success = GlobalMemoryStatusEx(mem_stat);
ram_ptr = &(mem_stat->ullAvailPhys);

As I’m sure you can guess, this code simply gets the available memory using the MEMORYSTATUSEX struct returned by GlobalMemoryStatusEx.

When I try to compile, I get this error:

error: unknown type name 'MEMORYSTATUSEX'

I looked in winbase.h (in the MinGW installation include folder) and guess what I found?

#if (_WIN32_WINNT >= 0x0500)
typedef struct _MEMORYSTATUSEX {
    DWORD dwLength;
    DWORD dwMemoryLoad;
    DWORDLONG ullTotalPhys;
    DWORDLONG ullAvailPhys;
    DWORDLONG ullTotalPageFile;
    DWORDLONG ullAvailPageFile;
    DWORDLONG ullTotalVirtual;
    DWORDLONG ullAvailVirtual;
    DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX,*LPMEMORYSTATUSEX;
#endif

So it’s there. I’m guessing this has something to do with the precompiler if/endif, but I don’t how to fix that….

Also what’s even more bizzare is that if I use the MEMORYSTATUS struct instead, it works fine.

According to the MS docs, both have the same minimum client version requirement:

MEMORYSTATUSEX:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366589%28v=vs.85%29.aspx

MEMORYSTATUS:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366772%28v=vs.85%29.aspx

Is there some compiler flag I need to set? Or does anyone have any other solutions?

Thanks in advance for your help!

  • 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-17T04:18:06+00:00Added an answer on June 17, 2026 at 4:18 am

    Apparently you have to define _WIN32_WINNT yourself either as a compiler flag or definition statement in one of your header/source files for this particular function to work properly.

    Adding the #define _WIN32_WINNT 0x0500 will allow the code to compile normally.

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

Sidebar

Related Questions

I'm trying to get sqlite3 c-api to compile under windows with code:blocks/gcc mingw compiler
I am trying to compile this .c code in windows using MinGW (gcc file.c
I'm trying to debug a Windows program compiled using MinGW's gcc that only ever
I am using Code-Blocks with the mingw GCC compiler for windows to code my
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,m using gcc compiler(MinGW) on Windows XP.I created a .dll library libdir.dll than I
First off, I am using python[2.7.2], numpy[1.6.2rc1], cython[0.16], gcc[MinGW] compiler, on a windows xp
I'm trying to compile this program using MinGW on Windows 7. On my first
I am using eclipse 3.7.2 and uses MinGW gcc 4.6.1 as my compiler. every

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.