473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

what is size of this macro?

#define PI 3.12

Aug 8 '06 #1
19 8444


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
2
by: Søren Nøhr Christensen | last post by:
Hi all! I was wondering how much overhead was involved in using a bitarray. In other words, how much space does an array of say 32bit use? snc
11
by: javadesigner | last post by:
Hi: I am a bit new to C programming and am trying to write a wrapper around malloc. Since malloc takes size_t as it's parameter, I want to be able to see if my function recieved an argument...
21
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
2
by: kleutervreter | last post by:
Other than the fact that the macro below implies fixed size buffers, is it unsafe to use? #define MEMSET( __v__, __s__ ) memset( (__v__), 0x00, (__s__) )
10
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and the exercise I'm working on is basically as follows: 1) Create a struct type with 4 members (char, char, char, int). 2) Create an array of, say 3 instances of...
4
by: jerico | last post by:
Hi.Does a macro increase the size of the executable ?On which factors the size of a executable depends? Jerico
7
by: miaohua1982 | last post by:
the code is as follows: #include<stdio.h> int arr={1,2,3,4,5,6,7}; #define size (sizeof(arr)/sizeof(arr)) int main() { int index = -1; int x = 0; int t;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.