473,320 Members | 1,876 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 exactly is the compiler thinking?

Visual Studio .Net 2003 Enterprise Architect. (VC++ code)

a developer in our team made a typo and his code looks like this

if (sendMessage == NULL)
m_ErrorCode = 0 ERR_MESSAGE_EMPTY;

But the compiler did not crib at all ! everything built fine....

is this a .Net compiler thing or is it some whacky C++ standard that
we are not aware of? (we do not know of any standards that specify the
occurence of a space char as anything other than a space char).

-Vinayak
Nov 17 '05 #1
6 1030
Vinayak Raghuvamshi wrote:
Visual Studio .Net 2003 Enterprise Architect. (VC++ code)

a developer in our team made a typo and his code looks like this

if (sendMessage == NULL)
m_ErrorCode = 0 ERR_MESSAGE_EMPTY;

But the compiler did not crib at all ! everything built fine....

is this a .Net compiler thing or is it some whacky C++ standard that
we are not aware of? (we do not know of any standards that specify the
occurence of a space char as anything other than a space char).

-Vinayak


What's the definition of ERR_MESSAGE_EMPTY? If it's a macro, you can compile
with /P and view the .i file that is produced to see the result of
preprocessing.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2
On 15 Jul 2004 07:10:21 -0700, vs************@hotmail.com (Vinayak
Raghuvamshi) wrote:
Visual Studio .Net 2003 Enterprise Architect. (VC++ code)

a developer in our team made a typo and his code looks like this

if (sendMessage == NULL)
m_ErrorCode = 0 ERR_MESSAGE_EMPTY;

But the compiler did not crib at all ! everything built fine....

is this a .Net compiler thing or is it some whacky C++ standard that
we are not aware of? (we do not know of any standards that specify the
occurence of a space char as anything other than a space char).


What is the definition of ERR_MESSAGE_EMPTY? If it's

#define ERR_MESSAGE_EMPTY +0

then I don't see the problem. We need a short and complete repro case
or it's a bit hard to comment...

Tom
Nov 17 '05 #3
If say ERR_MESSAGE_EMPTY is defined as
#define ERR_MESSAGE_EMPTY 12
then the compiler would have cribed as
error C2143: syntax error : missing ';' before 'constant'

but if ERR_MESSAGE_EMPTY is defined as any expression like
#define ERR_MESSAGE_EMPTY +12
or simply
#define ERR_MESSAGE_EMPTY

Then the meaning of that line would become
either m_ErrorCode = 0 +12; or m_ErrorCode = 0;

which is just fine. Either use /P to get the preprocessed file to see what
the expression is resulting into or go to
Project->properties->Preprocessor->Generate Preprocessed file (which inserts
/P is you compiler option)
Nov 17 '05 #4
"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message news:<an********************************@4ax.com>. ..
Vinayak Raghuvamshi wrote:
Visual Studio .Net 2003 Enterprise Architect. (VC++ code)

a developer in our team made a typo and his code looks like this

if (sendMessage == NULL)
m_ErrorCode = 0 ERR_MESSAGE_EMPTY;

But the compiler did not crib at all ! everything built fine....
.....
-Vinayak


What's the definition of ERR_MESSAGE_EMPTY? If it's a macro, you can compile
with /P and view the .i file that is produced to see the result of
preprocessing.


Sorry, My Bad. ERR_MESSAGE_EMPTY was defined as -17 :-(

I am already feeling very stupid and feel like eating my shoe...

thanks for the response, though.

-Vinayak
Nov 17 '05 #5
Vinayak Raghuvamshi wrote:
"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message news:<an********************************@4ax.com>. ..
Vinayak Raghuvamshi wrote:
>Visual Studio .Net 2003 Enterprise Architect. (VC++ code)
>
>a developer in our team made a typo and his code looks like this
>
>if (sendMessage == NULL)
> m_ErrorCode = 0 ERR_MESSAGE_EMPTY;
>
>But the compiler did not crib at all ! everything built fine....
> .....
>-Vinayak


What's the definition of ERR_MESSAGE_EMPTY? If it's a macro, you can compile
with /P and view the .i file that is produced to see the result of
preprocessing.


Sorry, My Bad. ERR_MESSAGE_EMPTY was defined as -17 :-(


To fix the problem and avoid it in the future, you can enclose it in
parentheses or change it from a macro to a const int.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #6
Also keep that shoe away ;-)

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com /* MVP tips tricks and essays web site */
http://blog.voidnish.com /* My blog on C++/CLI, MFC, Whidbey, CLR... */
"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message
news:4t********************************@4ax.com...
Vinayak Raghuvamshi wrote:
"Doug Harrison [MVP]" <ds*@mvps.org> wrote in message news:<an********************************@4ax.com>. ..
Vinayak Raghuvamshi wrote:

>Visual Studio .Net 2003 Enterprise Architect. (VC++ code)
>
>a developer in our team made a typo and his code looks like this
>
>if (sendMessage == NULL)
> m_ErrorCode = 0 ERR_MESSAGE_EMPTY;
>
>But the compiler did not crib at all ! everything built fine....
> .....
>-Vinayak

What's the definition of ERR_MESSAGE_EMPTY? If it's a macro, you can compile with /P and view the .i file that is produced to see the result of
preprocessing.


Sorry, My Bad. ERR_MESSAGE_EMPTY was defined as -17 :-(


To fix the problem and avoid it in the future, you can enclose it in
parentheses or change it from a macro to a const int.

--
Doug Harrison
Microsoft MVP - Visual C++

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
17
by: Mike Hofer | last post by:
While I'd toyed with C, C++, and Java over the last 20 years or so, my principal language has been BASIC, QBASIC, then Visual Basic, and finally Visual Basic .NET. But lately, I've been using C#...
16
by: Bob Hairgrove | last post by:
Consider the classic clone() function: class A { public: virtual ~A() {} virtual A* clone() const = 0; }; class B : public A { public:
9
by: ziman137 | last post by:
Hi all, The results from following codes got me a bit confused. #include <stdio.h> #include <iostream> using namespace std; struct A {
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
30
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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.