473,813 Members | 2,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it just me or just Microsoft?

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(78); //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
Jul 15 '07
40 2764
Neelesh Bodas wrote:
On Jul 15, 8:37 am, "Alf P. Steinbach" <al...@start.no wrote:
* Alf P. Steinbach:
* Ark Khasin:
>int main(int argc)
>{
> static int y=MYNUM(21); //error!
Just another suggestion: your "main" signature is incorrect.
I guess the standard expects the implementations to support the two
"standard" signatures, but it also says that other signatures are
allowed as far as return type is int:
So? That just makes it non-standard extension. It is incorrect within
the scope of either of these newsgroups.

Brian
Jul 15 '07 #11
Erik de Castro Lopo wrote:
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?
Only the truly perverse think that "complies to ISO 9899:1990" implies
the presence on C99 additions. In no way does their absence invalidate
Mr. Vandervies's claim.
Jul 15 '07 #12
Neelesh Bodas said:

<snip>
<quote>
3.6.1.2:
(main) function shall not be overloaded.
No, there is no section 3.6.1.2 in the Standard. There is a section
3.6(1), however, which says: "byte - addressable unit of data storage
large enough to hold any member of the basic character set of the
execution environment". I'm not sure how this is relevant to the fact
that your main declarator is broken.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 15 '07 #13
Erik de Castro Lopo wrote:
:: 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?

That wasn't available in 1990, was it?
Bo Persson
Jul 15 '07 #14
Dave Vandervies wrote:
:: In article <46************ ***********@roa drunner.com>,
:: GeekBoy <ge**@com.comwr ote:
:::
::: "Ark Khasin" <ak*****@macroe xpressions.comw rote in message
::: news:Pbfmi.4059 $7R4.1870@trndn y09...
:::: 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.

There are only two versions of the C++ standard, 1998 and 2003.

VC6 predates both of them, which you will notice if you try some
templated code, for example.
Bo Persson
Jul 15 '07 #15
Erik de Castro Lopo wrote:
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?
What does this all have to do with C90 compliance?

Jul 15 '07 #16
Richard Heathfield wrote:
Neelesh Bodas said:

<snip>
><quote>
3.6.1.2:
(main) function shall not be overloaded.

No, there is no section 3.6.1.2 in the Standard. There is a section
3.6(1), however, which says: "byte - addressable unit of data storage
large enough to hold any member of the basic character set of the
execution environment". I'm not sure how this is relevant to the fact
that your main declarator is broken.
It seems that both of you didn't notice that this thread goes to both
comp.lang.c and comp.lang.c++. It's likely that you are talking about
different standards.

Jul 15 '07 #17
On 2007-07-15 06:41, Erik de Castro Lopo wrote:
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?
Of course not, he said ISO 9899:1990, that's 9 years to early.

--
Erik Wikström
Jul 15 '07 #18
On 2007-07-15 10:59, Bo Persson wrote:
Dave Vandervies wrote:
:: In article <46************ ***********@roa drunner.com>,
:: GeekBoy <ge**@com.comwr ote:
:::
::: "Ark Khasin" <ak*****@macroe xpressions.comw rote in message
::: news:Pbfmi.4059 $7R4.1870@trndn y09...
:::: 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.

There are only two versions of the C++ standard, 1998 and 2003.
And a C standard released 1990.

--
Erik Wikström
Jul 15 '07 #19
On 2007-07-15 03:59, Ark Khasin wrote:
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(78); //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?
It works fine for me in VS2005, I suggest you check your compiler options.

--
Erik Wikström
Jul 15 '07 #20

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

Similar topics

99
6257
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a small or mid-sized business. http://groups-beta.google.com/group/microsoft.public.msdn.general/browse_thread/thread/9d7e8f9a00c1c7da/459ca99eb0e7c328?q=%22Proposed+MSDN+subscription+changes%22&rnum=1#459ca99eb0e7c328 Damn! To be that...
3
1750
by: Rahul Agarwal | last post by:
Hi In our web page we use a combination of HTML and server side controls and some of them have a custom attribute based on which we need to find and replace the values once the HTML is ready. For e.g. <LABEL DICTCODE="XYZ">Some text</LABEL> At run time just before the complete HTML is sent to the client-side I want to get hold of the HTML so that I can find and replace all the HTML elements
7
2177
by: GeorgeAtkins | last post by:
I want to create a web-based form or page that consists of a series of formatted questions and answers. The form will resemble an existing paper form. When the form is filled in, I want the user to submit the form via e-mail and have the complete form with answers sent, not just the data. That is, the recipient should be able to open the attachment and see (and print) the complete, formatted form. It seems to me that solutions simply...
0
9607
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,...
0
10669
Oralloy
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...
0
10407
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7684
isladogs
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...
0
5569
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...
0
5706
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
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
2
3885
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.