Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what is size of this macro?

3 views
Skip to first unread message

venkatesh...@gmail.com

unread,
Aug 8, 2006, 3:37:57 PM8/8/06
to
#define PI 3.12

Eric Sosman

unread,
Aug 8, 2006, 3:44:04 PM8/8/06
to

venkatesh...@gmail.com wrote On 08/08/06 15:37,:
> #define PI 3.12

Mu.

--
Eric....@sun.com

venkatesh...@gmail.com

unread,
Aug 8, 2006, 3:51:53 PM8/8/06
to
I mean how much memory it will take?

Tak-Shing Chan

unread,
Aug 8, 2006, 3:51:59 PM8/8/06
to
On Tue, 8 Aug 2006, venkatesh...@gmail.com wrote:

> #define PI 3.12

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

Tak-Shing

Frederick Gotham

unread,
Aug 8, 2006, 3:53:45 PM8/8/06
to
venkatesh...@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

venkatesh...@gmail.com

unread,
Aug 8, 2006, 3:59:56 PM8/8/06
to

But how is it? compiler will allocate memory.

Vlad Dogaru

unread,
Aug 8, 2006, 4:09:58 PM8/8/06
to
venkatesh...@gmail.com wrote:
> #define PI 3.12

Mine shows 3.14, but maybe your's is late. Are the batteries dead? ;)

Richard Heathfield

unread,
Aug 8, 2006, 4:10:58 PM8/8/06
to
venkatesh...@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)

Christopher Benson-Manica

unread,
Aug 8, 2006, 4:12:58 PM8/8/06
to
Vlad Dogaru <ddv...@gmail.com> wrote:

> 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.

venkatesh...@gmail.com

unread,
Aug 8, 2006, 4:18:34 PM8/8/06
to


Coz macro's are processed in CPP.

Default User

unread,
Aug 8, 2006, 4:22:21 PM8/8/06
to
venkatesh...@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.

J. J. Farrell

unread,
Aug 8, 2006, 4:47:27 PM8/8/06
to

venkatesh...@gmail.com wrote:
> Richard Heathfield wrote:
> > venkatesh...@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.

Keith Thompson

unread,
Aug 8, 2006, 4:58:53 PM8/8/06
to
"venkatesh...@gmail.com" <venkatesh...@gmail.com> writes:
> #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.

Eric Sosman

unread,
Aug 8, 2006, 5:00:14 PM8/8/06
to

venkatesh...@gmail.com wrote On 08/08/06 15:51,:
[top-posting fixed]


> Eric Sosman wrote:
>
>>venkatesh...@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.

--
Eric....@sun.com

Richard Heathfield

unread,
Aug 8, 2006, 5:58:37 PM8/8/06
to
venkatesh...@gmail.com said:

>
> Richard Heathfield wrote:
>> venkatesh...@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.

Joe Wright

unread,
Aug 8, 2006, 7:10:56 PM8/8/06
to
venkatesh...@gmail.com wrote:
> Tak-Shing Chan wrote:
>> On Tue, 8 Aug 2006, venkatesh...@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 ---

Keith Thompson

unread,
Aug 8, 2006, 8:19:55 PM8/8/06
to
Joe Wright <joeww...@comcast.net> writes:
> venkatesh...@gmail.com wrote:
>> Tak-Shing Chan wrote:
>>> On Tue, 8 Aug 2006, venkatesh...@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".

my.corre...@gmail.com

unread,
Aug 8, 2006, 10:14:29 PM8/8/06
to

Eric Sosman wrote:

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

Richard Bos

unread,
Aug 9, 2006, 4:19:12 AM8/9/06
to
Christopher Benson-Manica <at...@ukato.freeshell.org> wrote:

> Vlad Dogaru <ddv...@gmail.com> wrote:
>
> > 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

Ancient_Hacker

unread,
Aug 9, 2006, 6:43:11 AM8/9/06
to

venkatesh...@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.

0 new messages