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 40 2763
"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):
#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?
Yeah, buy a compiler that is ANSI/ISO compliant
>
Thank you,
Ark
GeekBoy wrote:
"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):
#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?
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
In article <46************ ***********@roa drunner.com>,
GeekBoy <ge**@com.comwr ote:
> "Ark Khasin" <ak*****@macroe xpressions.comw rote in message news:Pbfmi.405 9$7R4.1870@trnd ny09...
>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 dj******@csclub .uwaterloo.ca
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
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
In article <i1gmi.4064$7R4 .1703@trndny09> ,
Ark Khasin <ak*****@macroe xpressions.comw rote:
>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 dj******@csclub .uwaterloo.ca
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
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(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?
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
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
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?
And what do C99 functions have to do with C90 (OP spec'ed 9899:1990)
compliance?
On Jul 15, 8:37 am, "Alf P. Steinbach" <al...@start.no wrote:
* 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):
[unnecessary stuff chopped off]
int main(int argc)
{
static int y=MYNUM(21); //error!
Just another suggestion: your "main" signature is incorrect.
Not really. The following code compiles well on comeau online:
int main(int argc)
{
return 1;
}
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:
<quote>
3.6.1.2:
(main) function shall not be overloaded. It shall have a return type
of type int, but otherwise its type is implementation-defined. All
implementations shall allow both of the following efinitions of
main.....
</quote>
-N This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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
|
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...
|
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,...
|
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...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |