This is taken from page 90 in "The C Programming Language" by Kernighan
and Richtie.
They have the debugging print macro:
#define dprint(expr) printf(#expr " = %g \n", expr)
Which is invoked as in:
dprint(x/y);
The question is, does dprint(x/y) get expanded every time the program
is run (ie I compile it once, but run the program like 200 times), or
only once when the program gets compiled? 3 1813
"Chad" <cd*****@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com... This is taken from page 90 in "The C Programming Language" by Kernighan and Richtie.
They have the debugging print macro:
#define dprint(expr) printf(#expr " = %g \n", expr)
Which is invoked as in:
dprint(x/y);
The question is, does dprint(x/y) get expanded every time the program is run (ie I compile it once, but run the program like 200 times), or only once when the program gets compiled?
All preprocessing tokens are translated at compile time.
-Mike
Mike Wahler wrote: "Chad" <cd*****@gmail.com> wrote in message news:11*********************@g49g2000cwa.googlegro ups.com... This is taken from page 90 in "The C Programming Language" by Kernighan and Richtie.
They have the debugging print macro:
#define dprint(expr) printf(#expr " = %g \n", expr)
Which is invoked as in:
dprint(x/y);
The question is, does dprint(x/y) get expanded every time the program is run (ie I compile it once, but run the program like 200 times), or only once when the program gets compiled?
All preprocessing tokens are translated at compile time.
-Mike
So in other words, the expression dprint(x/y) doesn't get expanded
every time I run the program?
Chad wrote: Mike Wahler wrote: "Chad" <cd*****@gmail.com> wrote in message news:11*********************@g49g2000cwa.googlegro ups.com... This is taken from page 90 in "The C Programming Language" by Kernighan and Richtie.
They have the debugging print macro:
#define dprint(expr) printf(#expr " = %g \n", expr)
Which is invoked as in:
dprint(x/y);
The question is, does dprint(x/y) get expanded every time the program is run (ie I compile it once, but run the program like 200 times), or only once when the program gets compiled?
All preprocessing tokens are translated at compile time.
-Mike
So in other words, the expression dprint(x/y) doesn't get expanded every time I run the program?
.......yes, before actual compilation, the C preprocessor replaces all
"dprint(expr)" statements with printf(#expr " = %g \n", expr). So it
has nothing to do with runtime.
- Singamsetty This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Raghuveer Pallikonda |
last post by:
Hi,
I am trying to stub out debug log messages in my application, if
the logging subsystem is not enabled.. For e.g a invocation
#define LOGMSG !Logger::Enabled() ? false : Logger::LogMsg
so...
|
by: Siemel Naran |
last post by:
#define EXPECT_ASSERT(x) { if (!x) expect_assert(localVariable, __FILE__,
__LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first
nonwhite space".
|
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....
|
by: Malcolm |
last post by:
Hi,
I have the following which fails with "disagreement in number of macro
arguments" when compiling with Imagecraft ICCAVR. Has anyone got any
ideas - its not vital but would make the code a...
|
by: Rodolfo |
last post by:
Hello, there's another languages that can do a macro substitution, how can I
do this in Csharp.
This is an example of what I want to do
Dataset ds = new Dataset;
string a = "ds";
DataSet...
|
by: Don |
last post by:
I think "macro substitution" is the correct term for what I want to do, but,
to be sure, here is a description of what I'd like to know is possible:
I want to be able to create a create an object...
|
by: junky_fellow |
last post by:
hi guys,
Can you please suggest that in what cases should a macro be
preferred over inline function and viceversa ? Is there any case where
using a macro will be more efficient as compared to...
|
by: todWulff |
last post by:
Good day folks.
Let me open with the statement that I am not a C++/C programmer. The environment that I am programming in is ARMbasic, an embedded BASIC targeted toward ARM-based...
|
by: andersond |
last post by:
I have previously asked a question with the same title line but my situation and purpsse are different this time. I mean to be creating a function to go back over a form, identify blank required...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |