Re: What exactly is the compiler thinking?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 07/16/04


Date: Fri, 16 Jul 2004 17:17:47 -0500

Vinayak Raghuvamshi wrote:

>"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message news:<an8df0hpafjd13d266e3t4nq4045tj08p6@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++


Relevant Pages

  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... > of a macro within parentheses. ... if you enclose the parameters ... Randy Hyde ...
    (alt.lang.asm)
  • Re: C99: Suggestions for style(9)
    ... because it does not improve maintainability in any way. ... There is no source for confusion here, so the rule even contradicts the rule, which states not to use redundant parentheses. ... so it is clear that there is a macro at work. ... the parentheses are not redundant) would be for local debugging ...
    (freebsd-hackers)
  • Re: Casting the return value of malloc()...
    ... If the operand is a macro, and the macro is defined in such a way that ... parentheses are necessary, *fix the macro definition*. ... enclose the operand in parentheses or omit the parentheses. ... Idiom is more robust. ...
    (comp.lang.c)
  • Re: rvalue
    ... >The outer parentheses surrounding the entire macro definition are ... >necessary (and the original version of the macro had them). ... >referring to parentheses around each parameter reference within the ... >certain about the parentheses surrounding mw; ...
    (comp.lang.c)
  • Re: passing a multi dimensional array as a parameter, or returning one from a function
    ... enclose the args of a sub in parentheses if you use "call." ... I am trying to either pass in a multi dimensional array as a parameter ... This doesn't even compile though with an error of: Compile Error: ...
    (microsoft.public.office.developer.vba)