I'd like to know the size of a float
in GCC, without having to run the compiler. I know one option is to write a small function and have the compiler print out an assembly listing.
There is limits.h
, which contains the minimums and maximums, but is there something similar that tells the size of the different implicit types?
I'm using GCC on Windows 7 x64; the target platform is ARM7 32 bit mode. Language is C.
You can have GCC print out all of the default macros:
gcc -dM -E - </dev/null | grep FLT
Then you get lines like:
#define __FLT_MANT_DIG__ 24
#define __FLT_MAX_EXP__ 128
Now you can parse this as follows:
24 + lg(128) + 1 = 32
To find documentation:
1) man gcc
:
-E Stop after the preprocessing stage; do not run the compiler proper.
The output is in the form of preprocessed source code, which is
sent to the standard output.
...
-dCHARS
CHARS is a sequence of one or more of the following characters, and
must not be preceded by a space. Other characters are interpreted
by the compiler proper, or reserved for future versions of GCC, and
so are silently ignored. If you specify characters whose behavior
conflicts, the result is undefined.
M Instead of the normal output, generate a list of #define
directives for all the macros defined during the execution of
the preprocessor, including predefined macros. This gives you
a way of finding out what is predefined in your version of the
preprocessor. Assuming you have no file foo.h, the command
touch foo.h; cpp -dM foo.h
will show all the predefined macros.
2) the actual macros:
http://www.gnu.org/s/hello/manual/libc/Floating-Point-Parameters.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With