S
Stuart Redmann
[snipped discussion about whether calling convention modifiers make
code non-standard compliant]
Right. I think the error I made was that I assumed that declarations
of standardized STL classes from MS's STL headers would be portable.
Now I realize that they are not (even though they boil down to the
standard declaration when we strip off MS's extensions). I should bear
that in mind when I copy supposedly standard-compliant code from MS's
headers. I think that I got the picture now.
Thanks.
This is from VC6.0 as well as VC 2008 (without any Platform SDK).
I just posted some code of mine to someone else who has a different
compiler. I didn't realize that my code was full of MS's extensions
that would not work on his compiler. My mistake.
Many thanks,
Stuart
code non-standard compliant]
The code in question is from MS's ostream header (in the code I have
posted recently I took the liberty to replace the type _Myt with
std:stream, but it is actually typedef'ed as basic_ostream<_E,
_Tr>):template<class _E, class _Tr = char_traits<_E> >
class basic_ostream : virtual public basic_ios<_E, _Tr> {
public:
typedef basic_ostream<_E, _Tr> _Myt;[snip]
_Myt& operator<<(_Myt& (__cdecl *_F)(_Myt&))
{
return ((*_F)(*this));
}
[snip]
I understand that above definition adds a definition that is not part
of the standard. So it would be still right to say that MS's iostream
header is not standard-conformant because it lacks the required
operator that takes standard IO manipulators, wouldn't it?
The *contents* of the ostream header (and any other standard header)
should largely be considered totally non-portable. IOW, you cannot
expect MS's ostream for VC++ to do anything, even compile, on another
platform, even another MS platform, or even a different version of VC+
+.
Right. I think the error I made was that I assumed that declarations
of standardized STL classes from MS's STL headers would be portable.
Now I realize that they are not (even though they boil down to the
standard declaration when we strip off MS's extensions). I should bear
that in mind when I copy supposedly standard-compliant code from MS's
headers. I think that I got the picture now.
Thanks.
Nor does what you posted look quite like the code in VC++'s headers,
at least the couple of current versions that I took a look at. From
which version are you getting this? In any event, several definitions
of similar form are passing an explicit this pointer to the passed
function.
This is from VC6.0 as well as VC 2008 (without any Platform SDK).
But again, where are you going with this? Have you found some flaw in
VC++'s ostream implementation? Remember, *how* ostream (or anything
else) is implemented is implementation specific, just so long as it
does the right thing, as specified by the standard. How is this
(MSVC internal)code with the calling convention attribute impacting
your code? Or at least a problem from a compiler less than a dozen
years old, and from after the C++ standard was finished?
I just posted some code of mine to someone else who has a different
compiler. I didn't realize that my code was full of MS's extensions
that would not work on his compiler. My mistake.
Many thanks,
Stuart