#define EXPECT_ASSERT(x ) { if (!x) expect_assert(l ocalVariable, __FILE__,
__LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first
nonwhite space". 8 5344
"Siemel Naran" <Si*********@RE MOVE.att.net> wrote... #define EXPECT_ASSERT(x ) { if (!x) expect_assert(l ocalVariable, __FILE__, __LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
If you want to span a macro over several lines of code, you _have_ to end
all
but the last with a \:
#define EXPECT_ASSERT(x ) \
{ \
if (!x) \
expect_assert(l ocalVariable, \
__FILE__, \
__LINE__, \
#x \
); \
}
V
Siemel Naran wrote: #define EXPECT_ASSERT(x ) { if (!x) expect_assert(l ocalVariable, __FILE__, __LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
Add a backslash at the end of the first line.
--
Pete Becker
Dinkumware, Ltd. ( http://www.dinkumware.com)
Pete Becker <pe********@acm .org> wrote in message Siemel Naran wrote: #define EXPECT_ASSERT(x ) { if (!x) expect_assert(l ocalVariable, __FILE__, __LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
Add a backslash at the end of the first line.
Thanks. I guess by end of the first line you mean before the #x
(because different browsers/newsreaders page wrap differently). The
code below is two lines: line 1 starts with "#define" and ends with
"__LINE__, \", and line 2 starts with #x.
#define EXPECT_ASSERT(x ) { if (!(x)) expect_assert(o utputArgs,
__FILE__, __LINE__, \
#x); }
Anyway, is this behavior standard or Microsoft specific?
"Victor Bazarov" <v.********@com Acast.net> "Siemel Naran" <Si*********@RE MOVE.att.net> wrote...
#define EXPECT_ASSERT(x ) \ { \ if (!x) \ expect_assert(l ocalVariable, \ __FILE__, \ __LINE__, \ #x \ ); \ }
Thanks. This works, in addition to the suggestion Pete gave. Out of
curiosity, if have a macro
#define SOME_MACRO myfunction(__LI NE__)
and we rewrite it as
#define SOME_MACRO myfunction( \
__LINE__)
will the line number passed to myfunction be the same in the following
program:
int main() { // line 10
SOME_MACRO; // will this call myfunction(10) or myfunction(11)?
}
Thanks.
Siemel Naran wrote: "Victor Bazarov" <v.********@com Acast.net>
"Siemel Naran" <Si*********@RE MOVE.att.net> wrote...
#define EXPECT_ASSERT(x ) \ { \ if (!x) \ expect_assert(l ocalVariable, \ __FILE__, \ __LINE__, \ #x \ ); \ }
Thanks. This works, in addition to the suggestion Pete gave. Out of curiosity, if have a macro
#define SOME_MACRO myfunction(__LI NE__)
and we rewrite it as
#define SOME_MACRO myfunction( \ __LINE__)
will the line number passed to myfunction be the same in the following program:
int main() { // line 10 SOME_MACRO; // will this call myfunction(10) or myfunction(11)? }
Why don't you just try it? :-)
Well, concatenation of lines with the \ between them happens _before_ any
macro substitution. Since __LINE__ is a macro, the substitution has to
happen _after_ the concatenation, so the 'SOME_MACRO' example you gave
should be considered as a single line. That's basically how you can make
your macro register where it was placed in the code. Of course it does
*not* prevent you from doing
SOME_MACRO; SOME_MACRO;
and have two calls with the same value at run time, since both macros get
the same __LINE__ substitution.
V
Siemel Naran wrote: Pete Becker <pe********@acm .org> wrote in message
Siemel Naran wrote:
#define EXPECT_ASSERT(x ) { if (!x) expect_assert(l ocalVariable, __FILE__, __LINE__, #x); }
MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
Add a backslash at the end of the first line.
Thanks. I guess by end of the first line you mean before the #x (because different browsers/newsreaders page wrap differently). The code below is two lines: line 1 starts with "#define" and ends with "__LINE__, \", and line 2 starts with #x.
#define EXPECT_ASSERT(x ) { if (!(x)) expect_assert(o utputArgs, __FILE__, __LINE__, \ #x); }
Anyway, is this behavior standard or Microsoft specific?
The Standard requires that if you want something after # to be interpreted
as a preprocessor directive, there has to be nothing between the beginning
of the line and the #, except whitespace. IOW, on any _separate_ line of
code, if the preprocessor sees only whitespace followed by #, it tries to
interpret what follows the # as the directive.
V
"Victor Bazarov" <v.********@com Acast.net> wrote in message news:<3w8jd.372 421 #define EXPECT_ASSERT(x ) \ { \ if (!x) \
Also, we have to use parenthesis around x, as it might be a sentence,
not a simple variable.
if (!(x)) \ na*******@excit e.com (Siemel Naran) wrote: MSVC7 gives an error: "error C2014: preprocessor command must start as first nonwhite space".
The code below is two lines: line 1 starts with "#define" and ends with > "__LINE__, \", and line 2 starts with #x.
#define EXPECT_ASSERT(x ) { if (!(x)) expect_assert(o utputArgs, __FILE__, __LINE__, \ #x); }
Anyway, is this behavior standard or Microsoft specific?
This has got to be a compiler bug. I guess you will get the
same result if you write:
#define foo \
#x)
FWIW do you get an error if you go:
#define foo \
#error Error! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Rich Grise |
last post by:
I think I've finally found a tutorial that can get me started:
http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html
and I've been lurking for awhile as well. What happened is, I've
been playing with Qt in KDE on a Slackware 10.0 system, and following
their cookbook exercises, and everything's working, and I have no
clue what the code is doing, i.e.. how do I connect my brain to the
ascii in the files to the stuff on...
|
by: Steven T. Hatton |
last post by:
I'm serious about this folks! I really want to see the CPP obviated.
People who have never used tools such as JBuilder may not fully appreciate
the advantages they provide. This isn't about pointer safety, or making
sure you aren't blowing the bounds of an array. Imagine you could select a
namespace, enter a command with a new name as an argument, and your IDE
would rename every identifier qualified with that namespace to the new
name. ...
|
by: GS |
last post by:
I am doing my first real embedded programming project and the supplied
device libraries have a function definition that looks like this:
void FCN(void) = { INTDEF, INTABS, (unsigned short) PTRDEF};
where
INTDEF = some #defined integer
INTABS = some absolute integer (e.g. 2)
PTRDEF = some #defined pointer
|
by: Tin Gherdanarra |
last post by:
Hallo,
I'm trying to install pypgsql. However, I get syntax errors
while compiling the C sources. The following excerpt
from pgconnection.h looks a little funny to me:
typedef struct {
PyObject_HEAD /* Here is the syntax error, and rightly so */
PGconn *conn;
PyObject *host;
| |
by: Henry Townsend |
last post by:
Consider the little program below. It simply attempts to determine what
version of what compiler it was built with via documented preprocessor
macros and print out the result. When the compiler is gcc it works fine,
because __VERSION__ is supplied as a string. But identifying the Sun
compiler is harder because it provides __SUNPRO_C as a numerical value
(equal in my case to 0x580). My attempt to stringify it produces an error:
% cc -g -o...
|
by: Ravi |
last post by:
Hi,
I have this
#define KB 1
#define KB_AM 33
#define KB_RM 44
#define AM 2
#define RM 3
|
by: Chuck |
last post by:
Please help me correct the statements in sub "BoundData"
The following sub is in a module. Everything runs with no error messages,
however,data is not reaching the text box. Data is being appended to
WorkingTable but not filtered by value in text box. If I input data into the
text box, it gets deleted by the sub routine, indicating that
ctla.ItemData(varItm) is null.
Sub BoundData()
Dim frm As Form
|
by: babakandme |
last post by:
Hi everybody:D
I've a string that contains the name of a class.
Some members told that I can use """Stringizing Operator (#)""", but
the problem is here, that I have the string, & I want something vice-
versa.
As we know with """Stringizing Operator (#)""", we can get the stirng
name of a class or ... str <--- #ClassA
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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.
| |