Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is it just me or just Microsoft?

Reply
Thread Tools

Is it just me or just Microsoft?

 
 
Ark Khasin
Guest
Posts: n/a
 
      07-15-2007
Due to a peculiar need (code instrumentation) I came across unexpected
behavior of Visual Studio 6.0 and 2005 (doing the same thing):

#include <stdio.h>
#define CAT1(a,b) a ## b
#define CAT(a,b) CAT1(a,b)
#define MYNUM(n) CAT(n,__LINE__)
const int x = MYNUM(35); //OK
int z=MYNUM(7; //OK
int main(int argc)
{
static int y=MYNUM(21); //error!
//6.0: error C2064: term doesn't evaluate to a function
//2005 adds: taking 26451848 arguments.

printf("%d %d\n", x, y );
return 0;
}

Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
preprocessor is the same).
No problem with another compiler (IAR for ARM)...
[Microsoft claims strict standard compliance in the C++ department]

Any suggestions?

Thank you,
Ark
 
Reply With Quote
 
 
 
 
GeekBoy
Guest
Posts: n/a
 
      07-15-2007

"Ark Khasin" <(E-Mail Removed)> wrote in message
newsbfmi.4059$7R4.1870@trndny09...
> Due to a peculiar need (code instrumentation) I came across unexpected
> behavior of Visual Studio 6.0 and 2005 (doing the same thing):
>
> #include <stdio.h>
> #define CAT1(a,b) a ## b
> #define CAT(a,b) CAT1(a,b)
> #define MYNUM(n) CAT(n,__LINE__)
> const int x = MYNUM(35); //OK
> int z=MYNUM(7; //OK
> int main(int argc)
> {
> static int y=MYNUM(21); //error!
> //6.0: error C2064: term doesn't evaluate to a function
> //2005 adds: taking 26451848 arguments.
>
> printf("%d %d\n", x, y );
> return 0;
> }
>
> Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
> preprocessor is the same).
> No problem with another compiler (IAR for ARM)...
> [Microsoft claims strict standard compliance in the C++ department]
>
> Any suggestions?



Yeah, buy a compiler that is ANSI/ISO compliant


>
> Thank you,
> Ark



 
Reply With Quote
 
 
 
 
Ark Khasin
Guest
Posts: n/a
 
      07-15-2007
GeekBoy wrote:
> "Ark Khasin" <(E-Mail Removed)> wrote in message
> newsbfmi.4059$7R4.1870@trndny09...
>> Due to a peculiar need (code instrumentation) I came across unexpected
>> behavior of Visual Studio 6.0 and 2005 (doing the same thing):
>>
>> #include <stdio.h>
>> #define CAT1(a,b) a ## b
>> #define CAT(a,b) CAT1(a,b)
>> #define MYNUM(n) CAT(n,__LINE__)
>> const int x = MYNUM(35); //OK
>> int z=MYNUM(7; //OK
>> int main(int argc)
>> {
>> static int y=MYNUM(21); //error!
>> //6.0: error C2064: term doesn't evaluate to a function
>> //2005 adds: taking 26451848 arguments.
>>
>> printf("%d %d\n", x, y );
>> return 0;
>> }
>>
>> Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
>> preprocessor is the same).
>> No problem with another compiler (IAR for ARM)...
>> [Microsoft claims strict standard compliance in the C++ department]
>>
>> Any suggestions?

>
>
> Yeah, buy a compiler that is ANSI/ISO compliant
>
>
>> Thank you,
>> Ark

>

Easier said than done. Many people are bound to MS tools. I guess I
was asking for help with a workaround within MS if known.
- Ark
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-15-2007
* Ark Khasin:
> Due to a peculiar need (code instrumentation) I came across unexpected
> behavior of Visual Studio 6.0 and 2005 (doing the same thing):
>
> #include <stdio.h>
> #define CAT1(a,b) a ## b
> #define CAT(a,b) CAT1(a,b)
> #define MYNUM(n) CAT(n,__LINE__)
> const int x = MYNUM(35); //OK
> int z=MYNUM(7; //OK
> int main(int argc)
> {
> static int y=MYNUM(21); //error!
> //6.0: error C2064: term doesn't evaluate to a function
> //2005 adds: taking 26451848 arguments.
>
> printf("%d %d\n", x, y );
> return 0;
> }
>
> Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
> preprocessor is the same).
> No problem with another compiler (IAR for ARM)...
> [Microsoft claims strict standard compliance in the C++ department]
>
> Any suggestions?


Visual C++ __LINE__ is broken in many versions of that compiler, when
you compile with support for "Edit and Continue" (option /ZI), and that
may be what you're up against. As an alternative you can use
non-standard __COUNTER__. And the only thing that makes that compiler
specific information slightly on-topic here is that it's an issue with
Marginean's original scope guard (which is of general interest to the
C++ community), which needs to be modified for use with Visual C++.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Dave Vandervies
Guest
Posts: n/a
 
      07-15-2007
In article <469981e9$0$30620$(E-Mail Removed)>,
GeekBoy <(E-Mail Removed)> wrote:
>
>"Ark Khasin" <(E-Mail Removed)> wrote in message
>newsbfmi.4059$7R4.1870@trndny09...
>> Due to a peculiar need (code instrumentation) I came across unexpected
>> behavior of Visual Studio 6.0 and 2005 (doing the same thing):


[...]

>> Any suggestions?

>
>Yeah, buy a compiler that is ANSI/ISO compliant


MSVC6 complies to ISO 9899:1990 as well as any other compiler does when
it's invoked properly. Its C++ compiler pre-dates the last two versions
of the C++ standard and I don't have any experience with newer versions,
but I would be surprised if they don't at least closely approximate
compliance.

I'm unable to duplicate it with MSVC6, so it looks to me like it's
probably something specific to the OP's installation; but in any case
it's highly unlikely to be a deliberate non-compliance with the standard.


dave

--
Dave Vandervies http://www.velocityreviews.com/forums/(E-Mail Removed)
There are some rather entertaining LARTs that can be applied if you have the
will and moderately deep pockets to play with lawyers.
--Peter Corlett in the scary devil monastery
 
Reply With Quote
 
Ark Khasin
Guest
Posts: n/a
 
      07-15-2007
Dave Vandervies wrote:
<snip>
> MSVC6 complies to ISO 9899:1990 as well as any other compiler does when
> it's invoked properly.

<snip>

You must be kidding.
- Ark
 
Reply With Quote
 
Dave Vandervies
Guest
Posts: n/a
 
      07-15-2007
In article <i1gmi.4064$7R4.1703@trndny09>,
Ark Khasin <(E-Mail Removed)> wrote:
>Dave Vandervies wrote:
><snip>
>> MSVC6 complies to ISO 9899:1990 as well as any other compiler does when
>> it's invoked properly.

><snip>
>
>You must be kidding.
>- Ark


No, I'm not. I have a lot of reasons to hate Microsoft, but their C
compiler isn't one of them.


dave

--
Dave Vandervies (E-Mail Removed)
There are some rather entertaining LARTs that can be applied if you have the
will and moderately deep pockets to play with lawyers.
--Peter Corlett in the scary devil monastery
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-15-2007
* Alf P. Steinbach:
> * Ark Khasin:
>> Due to a peculiar need (code instrumentation) I came across unexpected
>> behavior of Visual Studio 6.0 and 2005 (doing the same thing):
>>
>> #include <stdio.h>
>> #define CAT1(a,b) a ## b
>> #define CAT(a,b) CAT1(a,b)
>> #define MYNUM(n) CAT(n,__LINE__)
>> const int x = MYNUM(35); //OK
>> int z=MYNUM(7; //OK
>> int main(int argc)
>> {
>> static int y=MYNUM(21); //error!
>> //6.0: error C2064: term doesn't evaluate to a function
>> //2005 adds: taking 26451848 arguments.
>>
>> printf("%d %d\n", x, y );
>> return 0;
>> }
>>
>> Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
>> preprocessor is the same).
>> No problem with another compiler (IAR for ARM)...
>> [Microsoft claims strict standard compliance in the C++ department]
>>
>> Any suggestions?

>
> Visual C++ __LINE__ is broken in many versions of that compiler, when
> you compile with support for "Edit and Continue" (option /ZI), and that
> may be what you're up against. As an alternative you can use
> non-standard __COUNTER__. And the only thing that makes that compiler
> specific information slightly on-topic here is that it's an issue with
> Marginean's original scope guard (which is of general interest to the
> C++ community), which needs to be modified for use with Visual C++.


Just another suggestion: your "main" signature is incorrect.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Ark Khasin
Guest
Posts: n/a
 
      07-15-2007
Alf P. Steinbach wrote:
> * Ark Khasin:
>> Due to a peculiar need (code instrumentation) I came across unexpected
>> behavior of Visual Studio 6.0 and 2005 (doing the same thing):
>>
>> #include <stdio.h>
>> #define CAT1(a,b) a ## b
>> #define CAT(a,b) CAT1(a,b)
>> #define MYNUM(n) CAT(n,__LINE__)
>> const int x = MYNUM(35); //OK
>> int z=MYNUM(7; //OK
>> int main(int argc)
>> {
>> static int y=MYNUM(21); //error!
>> //6.0: error C2064: term doesn't evaluate to a function
>> //2005 adds: taking 26451848 arguments.
>>
>> printf("%d %d\n", x, y );
>> return 0;
>> }
>>
>> Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
>> preprocessor is the same).
>> No problem with another compiler (IAR for ARM)...
>> [Microsoft claims strict standard compliance in the C++ department]
>>
>> Any suggestions?

>
> Visual C++ __LINE__ is broken in many versions of that compiler, when
> you compile with support for "Edit and Continue" (option /ZI), and that
> may be what you're up against. As an alternative you can use
> non-standard __COUNTER__. And the only thing that makes that compiler
> specific information slightly on-topic here is that it's an issue with
> Marginean's original scope guard (which is of general interest to the
> C++ community), which needs to be modified for use with Visual C++.
>

Alas, __COUNTER__ is not defined in 6.0. The rest works as explained.
Thank you so very much!
- Ark

 
Reply With Quote
 
Erik de Castro Lopo
Guest
Posts: n/a
 
      07-15-2007
Dave Vandervies wrote:

> MSVC6 complies to ISO 9899:1990 as well as any other compiler does when
> it's invoked properly.


Really? Do they have:

- New C99 math functions like lrint, lrintf, round etc ?
- A C99 compliant snprintf function?
- C99 variadic macros?

Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Circle is-a ellipse? Ellipse is-a circle? Ellipse has-a circle?"
-- Tommy McGuire
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it just me or just Microsoft? Ark Khasin C++ 24 07-16-2007 11:11 AM
How do I clean a virus within an inbox or just clean only that infectedattachment or LOCATE AND delete just that attachment ? Vinayak Firefox 1 08-14-2006 06:19 PM
Is there a Python MVC that works just as well with just CGI, or FCGI? walterbyrd Python 1 04-10-2006 07:57 PM
allow you to move just about any music to your iPud, MP3 player , or just burn it to disk sbcmynews Computer Support 4 05-01-2005 03:53 PM
Just bought a Digital Rebel just 1 question RacerX Digital Photography 7 11-21-2003 01:51 PM



Advertisments