Is MS C++ 7.0 ANSI compliant?
Is it? I'm starting my c (and later c++) classes right now and I have been using C# in the last years so I love Visual Studio and I'd love to be able to do my c/c++ programs there but I've heard MS C/c++ it is not ANSI compliant.
So..is it or not? My teacher says it is not but i thinnk he was talking about vc++ 6 or something along the lines
Re: Is MS C++ 7.0 ANSI compliant?
Quote:
Originally Posted by PT Exorcist
Is it? I'm starting my c (and later c++) classes right now and I have been using C# in the last years so I love Visual Studio and I'd love to be able to do my c/c++ programs there but I've heard MS C/c++ it is not ANSI compliant.
So..is it or not? My teacher says it is not but i thinnk he was talking about vc++ 6 or something along the lines
The microsoft C compiler is not compliant to the C (99) standard -- I think it's still stuck around C '89. For example, you must declare all variables at the beginning of a function using MS's compiler, while the 99 standard says this is not required.
The C++ compiler is much more standards compliant, but how much depends on whether you're talking about the version that comes with .NET 2003, .NET 2005, etc. I would wager that any of the C++ compilers can handle what you'll be doing in the class; the C compiler might not.
Re: Is MS C++ 7.0 ANSI compliant?
VC++ differs with GCC in where variables are declared.
In GCC you are allowed to declare a variable anywhere in a function, but for some reason when compiling with the "Compile to C Code" switch VC complains and makes you move all variable declarations to the top of the function.
I'm not sure what the ANSI standard has to say about this. It's onl 550 pages long so I should find something in there :)
Re: Is MS C++ 7.0 ANSI compliant?
C89 only allows declarations at the top of functions. VC is pretty much compliant with respect to C. I doubt the C++ compiler is 100% standards compliant, because C++ is incredibly hard to get right (and whether 'right' is what you want is debatable), but it is close enough (starting with 7.0).
By default GCC enables several extensions (such as allowing variable declarations everywhere), use the -ansi flag to switch to standard compliant mode.
Re: Is MS C++ 7.0 ANSI compliant?
Quote:
Originally Posted by twanvl
C89 only allows declarations at the top of functions. VC is pretty much compliant with respect to C. I doubt the C++ compiler is 100% standards compliant, because C++ is incredibly hard to get right (and whether 'right' is what you want is debatable), but it is close enough (starting with 7.0).
By default GCC enables several extensions (such as allowing variable declarations everywhere), use the -ansi flag to switch to standard compliant mode.
C89 only allows declarations at the top of functions, but C99 allows you to declare them everywhere. In this respect, VC is compliant, but to an outdated standard.
Re: Is MS C++ 7.0 ANSI compliant?
There exists no 100% compliant C++ compiler today. So much for that.
However, VC++ is, since version 7.1 (Visual Studio.Net 2003) pretty compliant, and even more compliant since version 8.0 (VS.Net 2005), although a lot of stupid stuff has been added in that most recent version too.
Version 7.0 (VS.Net 2002) is hardly an improvement over the very poorly compliant version 6.5 (VC++6, Service Pack 6). VC++6 itself is a desaster, although it has an excuse: it was published a few months before the C++ standard itself.
Re: Is MS C++ 7.0 ANSI compliant?
and about writting pure C code? will I have any kind of problems or nowadays all C compilers are ansi compliant?
Re: Is MS C++ 7.0 ANSI compliant?
Well I'm trying to write pure C code in linux. GCC is working fine, but if I turn on ANSI compliance mode it gives me a load of errors I cannot understand, so I don't. Also VC++ seems to be OK too. I've written a simple DLL in VC++ (using the ANSI C switch so it doesn't compile to C++) and its fairly decent. I used it from within a C# app with no problem at all.
I think that trying to conform ABSOLUTELY to the ANSI C standard is very hard to do and probably not worth the effort. GCC is good enough fo me and compiles small and fast binaries.
Re: Is MS C++ 7.0 ANSI compliant?
Quote:
Originally Posted by wossname
I think that trying to conform ABSOLUTELY to the ANSI C standard is very hard to do
I wouldn't know why. The C standard isn't that complex. It's mostly a matter of style.