Hi,
I know that when I use #define statements, the
preprocessor goes and replaces instances of where I have
used the definitions with what they are defined as, but my
question today is does it evaluate them first (if they
don't rely on variables)?
For instance if I have #define WHITE RGB(255, 255, 255)
does it simply replace instances of the word 'WHITE'
with 'RGB(255, 255, 255)' or does the preprocessor
actually run the RGB macro to work out what the *result*
of RGB(255, 255, 255) is and send that to the compiler? 2 1070
Hello,
Usually, the compiler will evaluate an expression that got immediates into
one result value.
So: WHITE will be replace with RBG(255,255,255 ) then if RGB is a macro and
is passed all constants then the compiler will evaluate to a constant.
However you can experiment w/ that using the Disassembly window. (vc6 key =
alt+8)
Regards,
Elias
The PREprocessor replaces exactly what you type. For example...
#define MULTIPLY(x, y) x * y
z = MULTIPLY(1+2, 3+4)
This becomes
z = 1+2 * 3+4;
The optimizing compiler will precalculate as much as possible. This is what
actually goes into your exe.
z = 11; // Not what you expected?
"Ben Taylor" <be***********@ yahoo.co.uk> wrote in message
news:0b******** *************** *****@phx.gbl.. . Hi, I know that when I use #define statements, the preprocessor goes and replaces instances of where I have used the definitions with what they are defined as, but my question today is does it evaluate them first (if they don't rely on variables)? For instance if I have #define WHITE RGB(255, 255, 255)
does it simply replace instances of the word 'WHITE' with 'RGB(255, 255, 255)' or does the preprocessor actually run the RGB macro to work out what the *result* of RGB(255, 255, 255) is and send that to the compiler? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nobody |
last post by:
hello!
do you know of any (free) preprocessor able to deal with
DTDs?
I'dlike to do things as
#define with_b
...
<!ELEMENT a (#PCDATA)>
<!ELEMENT c (#PCDATA)>
|
by: Jeremy Siek |
last post by:
CALL FOR PAPERS/PARTICIPATION
C++, Boost, and the Future of C++ Libraries
Workshop at OOPSLA
October 24-28, 2004
Vancouver, British Columbia, Canada
http://tinyurl.com/4n5pf
Submissions
|
by: Nudge |
last post by:
I have an array, and an unrolled loop which looks like this:
do_something(A);
do_something(A);
....
do_something(A);
I thought: why should I type so much? I should write a macro.
So I was looking to write something along the lines of:
|
by: Trying_Harder |
last post by:
Is it possible to redefine a macro with global scope after
undefining it in a function? If yes, could someone explain
how?
/If/ my question above isn't very clear you can refer to
the following example.
eg cosider 2 files sample.c and sample.h
sample.h
|
by: /* frank */ |
last post by:
My teacher said that array in C is managed by preprocessor.
Preprocesser replace all array occurences (i.e. int a ) with
something that I don't understand/remember well.
What's exactly happens with array during preprocessing/compiling stage?
Thanks in advance
| |
by: Chris Croughton |
last post by:
Is the following code standard-compliant, and if so what should it do?
And where in the standard defines the behaviour?
#include <stdio.h>
#define DEF defined XXX
int main(void)
{
int defined = 2;
|
by: Walter Roberson |
last post by:
I have run into a peculiarity with SGI's C compiler (7.3.1.2m). I have been
reading carefully over the ANSI X3.159-1989 specification, but I cannot
seem to find a justification for the behaviour. Could someone point
me to the appropriate section, or else confirm the behaviour as a bug?
For a particular project, I am using the C preprocessor phase only.
I am not using the standalone program 'cpp' because proper functioning
of my project...
|
by: spibou |
last post by:
Is the output of the C preprocessor deterministic ? What I mean
by that is , given 2 compilers which conform to the same standard,
will their preprocessors produce identical output given as input
the same file ? If not then how much variation is allowed ? Is it
just a bit more or less white space here and there or could could
there be larger differences ?
If the output is not deterministic then is it possible that the output
of the...
|
by: Sam of California |
last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing
of the source file"?
I responded to that comment by saying that the preprocessor is not just a
pass. It processes statements that the compiler does not process. The good
people in the alt.comp.lang.learn.c-c++ newsgroup insist that the
preprocessor is just one of many passes. The preprocessor processes a
grammer unique to the preprocessor and only that grammer.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |