I should have said I was using mingw-builds 4.8.2.
I assume this is the latest compiler I should use, yes?
I tried it with and without memset().

I had to rework my code to make an example you might be able to compile.
hmmph. I think as long as I was working on that prime numbers project, it was 
failing. things were going wrong all over. maybe I wasn't supposed to do that 
project. :-/

 
-------------
Jim Michaels
jmich...@yahoo.com
j...@renewalcomputerservices.com
http://RenewalComputerServices.com
http://JesusnJim.com (my personal site, has software)
---
IEC Units: Computer RAM & SSD measurements, microsoft disk size measurements 
(note: they will say GB or MB or KB or TB when it is IEC Units!):
[KiB] [MiB] [GiB] [TiB]
[2^10B=1,024^1B=1KiB]
[2^20B=1,024^2B=1,048,576B=1MiB]
[2^30B=1,024^3B=1,073,741,824B=1GiB]
[2^40B=1,024^4B=1,099,511,627,776B=1TiB]
[2^50B=1,024^5B=1,125,899,906,842,624B=1PiB]
SI Units: Hard disk industry disk size measurements:

[KB] [MB] [GB] [TB]
[10^3B=1,000B=1KB]
[10^6B=1,000,000B=1MB]
[10^9B=1,000,000,000B=1GB]
[10^12B=1,000,000,000,000B=1TB]
[10^15B=1,000,000,000,000,000B=1PB]





On Sunday, November 17, 2013 1:33 PM, niXman <i.nix...@autistici.org> wrote:
 
Jim Michaels писал 2013-11-18 01:12:
>> what's going on? GlobalMemoryStatusEx() always returns failure. I even
>> memset() the struct with 0's, no difference.
>> 
>> 
>> #include <iostream>
>> #Include <memory.h>
>> #include <windows.h>
>> #include <stdint.h>
>> #include <WinBase.h>
>> 
>> 
>> typedef uint64_t addressType; //with 64-bit boxes, there may be
>> support for __int128, but I guess not yet with some compilers
>> typedef uint64_t vecElementType;
>> MEMORYSTATUSEX mse;
>> 
>> addressType availableRAM(void) {
>>     memset(&mse,0, sizeof(MEMORYSTATUSEX));
>>     if (0==GlobalMemoryStatusEx(&mse)) {
>>         std::cout<<"GlobalMemoryStatusEx():ERROR\n";
>>         return 0;
>>     }
>>     addressType ram=mse.ullAvailPhys;
>>     std::cout<<"availableRam()="<<ram<<"\n";
>>     return ram; //do I need to use a percentage here? is there a
>> structure overhead with bitset?
>> }
>> int main(int argc, char * argv[]) {
>>     UINT_TYPE n=0;
>>     size_t sp,ep;
>> 
>>     availRam = availableRAM();
>>     if (0!=availRam) {
>>         availRam -= RESERVE_RAM;//2*2^30. we reserve 2GiB for
>> applications to run fast like browsers etc
>>     }
>>     return 0;
>> }
>
>Your code is wrong.
>Just now I have compiled and executed the code I got from MSDN site.
>
>//  Sample output:
>//  There is       51 percent of memory in use.
>//  There are 2029968 total KB of physical memory.
>//  There are  987388 free  KB of physical memory.
>//  There are 3884620 total KB of paging file.
>//  There are 2799776 free  KB of paging file.
>//  There are 2097024 total KB of virtual memory.
>//  There are 2084876 free  KB of virtual memory.
>//  There are       0 free  KB of extended memory.
>
>#include <windows.h>
>#include <stdio.h>
>#include <tchar.h>
>
>// Use to convert bytes to KB
>#define DIV 1024
>
>// Specify the width of the field in which to print the numbers.
>// The asterisk in the format specifier "%*I64d" takes an integer
>// argument and uses it to pad and right justify the number.
>#define WIDTH 11
>
>
>int main() {
>   MEMORYSTATUSEX statex;
>
>   statex.dwLength = sizeof (statex);
>
>   GlobalMemoryStatusEx (&statex);
>
>   _tprintf (TEXT("There is  %*ld percent of memory in use.\n"),
>             WIDTH, statex.dwMemoryLoad);
>   _tprintf (TEXT("There are %*I64d total KB of physical memory.\n"),
>             WIDTH, statex.ullTotalPhys/DIV);
>   _tprintf (TEXT("There are %*I64d free  KB of physical memory.\n"),
>             WIDTH, statex.ullAvailPhys/DIV);
>   _tprintf (TEXT("There are %*I64d total KB of paging file.\n"),
>             WIDTH, statex.ullTotalPageFile/DIV);
>   _tprintf (TEXT("There are %*I64d free  KB of paging file.\n"),
>             WIDTH, statex.ullAvailPageFile/DIV);
>   _tprintf (TEXT("There are %*I64d total KB of virtual memory.\n"),
>             WIDTH, statex.ullTotalVirtual/DIV);
>   _tprintf (TEXT("There are %*I64d free  KB of virtual memory.\n"),
>             WIDTH, statex.ullAvailVirtual/DIV);
>
>   // Show the amount of extended memory available.
>
>   _tprintf (TEXT("There are %*I64d free  KB of extended memory.\n"),
>             WIDTH, statex.ullAvailExtendedVirtual/DIV);
>}
>
>
>
>
>-- 
>Regards, niXman
>___________________________________________________
>Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
>http://sourceforge.net/projects/mingw-w64/
>___________________________________________________
>Another online IDE: http://liveworkspace.org/
>
>------------------------------------------------------------------------------
>DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
>OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
>Free app hosting. Or install the open source package on any LAMP server.
>Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
>http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
>_______________________________________________
>Mingw-w64-public mailing list
>Mingw-w64-public@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>
>
>
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to