468,512 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

what is size of this macro?

#define PI 3.12

Aug 8 '06 #1
19 6885


ve****************@gmail.com wrote On 08/08/06 15:37,:
#define PI 3.12
Mu.

--
Er*********@sun.com

Aug 8 '06 #2
I mean how much memory it will take?
Eric Sosman wrote:
ve****************@gmail.com wrote On 08/08/06 15:37,:
#define PI 3.12

Mu.

--
Er*********@sun.com
Aug 8 '06 #3
On Tue, 8 Aug 2006, ve****************@gmail.com wrote:
#define PI 3.12
3.12 is of type double, therefore sizeof PI is the same as
sizeof(double).

Tak-Shing
Aug 8 '06 #4
ve****************@gmail.com posted:
#define PI 3.12

It's about an inch and a half wide on my screen.

If you need it smaller, try changing screen resolution -- should shave off a
few clock cycles.

--

Frederick Gotham
Aug 8 '06 #5

But how is it? compiler will allocate memory.
Tak-Shing Chan wrote:
On Tue, 8 Aug 2006, ve****************@gmail.com wrote:
#define PI 3.12

3.12 is of type double, therefore sizeof PI is the same as
sizeof(double).

Tak-Shing
Aug 8 '06 #6
ve****************@gmail.com wrote:
#define PI 3.12
Mine shows 3.14, but maybe your's is late. Are the batteries dead? ;)

Aug 8 '06 #7
ve****************@gmail.com said:
>
But how is it? compiler will allocate memory.
Why?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Aug 8 '06 #8
Vlad Dogaru <dd****@gmail.comwrote:
Mine shows 3.14, but maybe your's is late. Are the batteries dead? ;)
It's 3.00 on mine, but I'm running on a King Solomon model, so
apparently it's a QOI issue.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Aug 8 '06 #9

Richard Heathfield wrote:
ve****************@gmail.com said:

But how is it? compiler will allocate memory.

Why?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)

Coz macro's are processed in CPP.

Aug 8 '06 #10
ve****************@gmail.com wrote:
I mean how much memory it will take?

Please read the information below.

Brian

--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup.
Aug 8 '06 #11

ve****************@gmail.com wrote:
Richard Heathfield wrote:
ve****************@gmail.com said:
>
But how is it? compiler will allocate memory.
Why?

Coz macro's are processed in CPP.
You are asking questions which don't make much sense, and making
statements which don't seem to be related to the questions or the
discussion. This suggests that you have some fundamental
misunderstanding of something. If you give a more complete description
of what is puzzling you, perhaps with some example code, we may be
better able to help you understand the issue.

Aug 8 '06 #12
"ve****************@gmail.com" <ve****************@gmail.comwrites:
#define PI 3.12
Please put the question in the body of your article. Not all newsreaders
show the subject along with the body of the message.

The question was "what is size of this macro?". As you say later,
you're asking how much memory is allocated.

The answer is none. Macros don't allocate memory; they perform
textual substitution on your source code.

By itself, the macro definition

#define PI 3.12

will simply disappear from your program if you don't use it.

If you do use it, each occurrence of PI in your source will simply be
replaced with 3.12. What this does depends on how you use it.

The literal 3.12 is of type double, if that's what you were wondering about.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 8 '06 #13


ve****************@gmail.com wrote On 08/08/06 15:51,:
[top-posting fixed]
Eric Sosman wrote:
>>ve****************@gmail.com wrote On 08/08/06 15:37,:
>>>#define PI 3.12

Mu.

I mean how much memory it will take?
"None." Or "sizeof(double)." Or "too much." All
these answers, and more, are defensible. The question
is not well-formed, and suggests that you may not quite
understand what macros are or how they operate in your
program source. I recommend that you return to your C
textbook and re-read the section on macros, and perhaps
write a few short programs with and without using macros
(other than those you simply cannot avoid if you want to
use the library functions). If things remain unclear,
come back and ask more questions -- but the question you
are asking now indicates there's a basic flaw somewhere
in your understanding.

--
Er*********@sun.com

Aug 8 '06 #14
ve****************@gmail.com said:
>
Richard Heathfield wrote:
>ve****************@gmail.com said:
>
But how is it? compiler will allocate memory.

Why?
Coz macro's are processed in CPP.
So what makes you think the compiler will allocate memory for PI? It won't
even /see/ PI, because - as you say - macros are processed by the
preprocessor.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Aug 8 '06 #15
ve****************@gmail.com wrote:
Tak-Shing Chan wrote:
>On Tue, 8 Aug 2006, ve****************@gmail.com wrote:
>>#define PI 3.12
3.12 is of type double, therefore sizeof PI is the same as
sizeof(double).

Tak-Shing

But how is it? compiler will allocate memory.
The compiler doesn't involve itself in #define thingies. The compiler
never sees PI. The preprocessor has already replaced PI with 3.12 and,
correct or not, this is what the compiler eventually sees.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Aug 8 '06 #16
Joe Wright <jo********@comcast.netwrites:
ve****************@gmail.com wrote:
>Tak-Shing Chan wrote:
>>On Tue, 8 Aug 2006, ve****************@gmail.com wrote:

#define PI 3.12
3.12 is of type double, therefore sizeof PI is the same as
sizeof(double).

Tak-Shing

But how is it? compiler will allocate memory.

The compiler doesn't involve itself in #define thingies. The compiler
never sees PI. The preprocessor has already replaced PI with 3.12 and,
correct or not, this is what the compiler eventually sees.
That's assuming that you don't consider the preprocessor to be part of
the "compiler".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 9 '06 #17

Eric Sosman wrote:
ve****************@gmail.com wrote On 08/08/06 15:37,:
#define PI 3.12

Mu.

--
Er*********@sun.com
Sometimes I wonder: Would I be happier if I didn't understand comments
like this one? Then again, the answer is Mu.

Aug 9 '06 #18
Christopher Benson-Manica <at***@ukato.freeshell.orgwrote:
Vlad Dogaru <dd****@gmail.comwrote:
Mine shows 3.14, but maybe your's is late. Are the batteries dead? ;)

It's 3.00 on mine, but I'm running on a King Solomon model, so
apparently it's a QOI issue.
It certainly is: the King Solomon Specification only specifies a single
digit of precision, so your model is giving you a precision that isn't
actually justified by the docs.

Richard
Aug 9 '06 #19

ve****************@gmail.com wrote:
I mean how much memory it will take?
#define PI 3.12

How much memory will WHAT take, when, and on which compiler, what
platform?

Choices for "what" and "when":

(1) The line of text, in the source file.
(2) The macro, in the compiler, at compile time.
(3) The macro, at link time.
(3) The macro, at run time

You may need to read up on macros, and exactly how they get processed.

Aug 9 '06 #20

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
7 posts views Thread by Newbie_sw2003 | last post: by
2 posts views Thread by Søren Nøhr Christensen | last post: by
11 posts views Thread by javadesigner | last post: by
21 posts views Thread by Niu Xiao | last post: by
2 posts views Thread by kleutervreter | last post: by
4 posts views Thread by jerico | last post: by
7 posts views Thread by miaohua1982 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.