Reputation: 5351
There was a program what I could compile under 2008 for a while. Note I can compile the program using cl and in Ultimate++ IDE. It is a fairly large program , so I am not going to post it here. I cannot compile it in Studio.
The error is
1>c:\program files\microsoft visual studio 9.0\vc\include\xstring(1735)
: error C2856: #pragma hdrstop cannot be inside an #if block
which seems to be idiotic as there is no hdrstop in there.
Precompiled headers are turned off.
This is what is there:
if (_Mysize < _Off)
_String_base::_Xran(); // _Off off end
if (_Mysize - _Off < _Count)
_Count = _Mysize - _Off;
_Traits_helper::copy_s<_Traits>(_Dest, _Dest_size, _Myptr() + _Off, _Count);
return (_Count);
}
void __CLR_OR_THIS_CALL swap(_Myt& _Right)
{ // exchange contents with _Right <<<<<<<<----------this is the line
if (this == &_Right)
; // same object, do nothing
else if (_Mybase::_Alval == _Right._Alval)
{ // same allocator, swap control information
Thanks.
Upvotes: 1
Views: 1528
Reputation: 5351
I found this out. It caused by precompiled headers, yes but there is no need to turn this off.
It happens when a top level #include "headertobeprecompiled.h"
is inside an #if
#endif
block. If one can move it outside that the error message disappears.
Upvotes: 4
Reputation: 625
I have experienced the exact same problem and was also puzzled since I don't have any hdrstop pragmas in my code, either. However, I compile from a script (not an IDE) and when I omit the compiler option /Yc (create PCH) the error disappears.
Upvotes: 0
Reputation: 6697
Wild guess.
The precompiled headers are switched off for the project? Are they switched off for every single source file in the project (cause individual file settings overwrite whole-project settings).
Upvotes: 3
Reputation: 13028
Because Visual C++ invokes cl (which works fine) and you obviously have messed up headers, the first thing I'd check are include paths. Post them here.
Upvotes: 0