This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Optimize causes an error.
- From: "Young, Michael" <Michael dot Young at paetec dot com>
- To: "LWATCDR" <lwatcdr at gmail dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Tue, 10 Jul 2007 18:03:33 -0400
- Subject: RE: Optimize causes an error.
> How the heck to I find out how much free memory I have in c?
I am unaware of how to do this using standard 'C/C++' without simply
allocating blocks (in smaller and smaller increments as the allocs fail)
until nothing more can be allocated. This is probably not what you want.
I think the answer you're looking for is in a function that reports the
amount of RAM installed and/or available to your process - that would be
a platform API (I know of no equivalent in the CRT or C++ Std Lib), so it
is necessarily OS dependent.
Regarding your original problem with optimization - I don't have a
definitive answer (which would be difficult anyway, because part of
the code is missing - this is not a "self-contained" example) but I do
have a recommendation (based on some "hard won experience") :
1) turn up warnings and pay attention to any that are emitted for this
section of code.
2) make sure you aren't comparing ints and unsigned ints
I really hope this helps and/or it's something as simple for you as this!
- Mike