By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,971 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,971 IT Pros & Developers. It's quick & easy.

What exactly is the compiler thinking?

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.