(too old to reply)
/Za option
pba
2005-10-24 23:03:27 UTC
Hi, does anybody know exactly what /Za cl option will do ?

What I'm interested in is what language constructs/extensions/macros
are set/unset. So far it seems that only _MSC_EXTENSIONS is not set and
__STDC__ is set.

Thanks!
Paul
John Carson
2005-10-24 23:38:50 UTC
Post by pba
Hi, does anybody know exactly what /Za cl option will do ?
What I'm interested in is what language constructs/extensions/macros
are set/unset. So far it seems that only _MSC_EXTENSIONS is not set
and __STDC__ is set.
Thanks!
Paul
Typing /Za in the index of Help should lead you to the required information
(which, if memory serves, differs slightly for different VC++ versions). In
practical terms, the compiler cannot successfully process windows.h if you
use /Za, which makes it basically useless for Windows programming.
--
John Carson
pba
2005-10-25 14:12:34 UTC
With VS 2003 it builds just fine, it accepts __declspec, xor and
__COUNTER__ - to name just a few extensions.
John Carson
2005-10-25 14:51:01 UTC
Post by pba
With VS 2003 it builds just fine, it accepts __declspec, xor and
__COUNTER__ - to name just a few extensions.
I am not sure if you read what I wrote. If I attempt to build the following
using /Za

#include "windows.h"
int main()
{}

then I get 49 errors.

It is true that you can still use some Microsoft specific code with /Za.
That, however, falls a long way short of allowing you to do most sorts of
Windows programming.
--
John Carson
pba
2005-11-01 18:49:33 UTC
I am not sure you read what I wrote : what I'm trying to find out is
what is left out and what gets in when you use /Za. Za is advertised to
disable MS extensions and is supposed to be used to check for
portability problems, and portability assumes - of course - you will
not be including any windows specific headers. To be more specific, I
expect the compilation of the following program to fail (note there are
no windows spec. hdrs ):

#include <iostream>
class __declspec(novtable) base
{
public:
virtual void beep() {}
};
class test : public base
{
public
void beep() {};
};
int main(void)
{
test *p = new test();
p->beep();
return (EXIT_SUCCESS);
}
Post by John Carson
Post by pba
With VS 2003 it builds just fine, it accepts __declspec, xor and
__COUNTER__ - to name just a few extensions.
I am not sure if you read what I wrote. If I attempt to build the following
using /Za
#include "windows.h"
int main()
{}
then I get 49 errors.
It is true that you can still use some Microsoft specific code with /Za.
That, however, falls a long way short of allowing you to do most sorts of
Windows programming.
--
John Carson
John Carson
2005-11-02 00:26:54 UTC
Post by pba
I am not sure you read what I wrote : what I'm trying to find out is
what is left out and what gets in when you use /Za. Za is advertised
to disable MS extensions and is supposed to be used to check for
portability problems, and portability assumes - of course - you will
not be including any windows specific headers. To be more specific, I
expect the compilation of the following program to fail (note there
#include <iostream>
class __declspec(novtable) base
{
virtual void beep() {}
};
class test : public base
{
public
void beep() {};
};
int main(void)
{
test *p = new test();
p->beep();
return (EXIT_SUCCESS);
}
According to the C++ standard, names with a double underscore are reserved
for compiler specific extensions. By definition, these are non-portable.
Thus, to adapt your remarks, "portability assumes - of course - you will
not be including any double underscore identifiers."

/Za doesn't automatically prevent your code from compiling when you use
these; I presume this is because the C++ standard makes provision for such
extensions. I agree that a switch that made the compiler reject all
extensions would be convenient for some purposes, but there just isn't one.

As previously indicated, you can find out what /Za covers by looking it up
in the Help file. When I do so, the /Za entry has a link to "Microsoft
Extensions to C and C++". That should tell you what /Za excludes (since this
may vary with compiler version, however, I recommend you look it up in the
help that came with your compiler).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_microsoft_extensions_to_c.asp
--
John Carson