Search code examples
visual-c++visual-c++-2008-express

What causes "error C2856: #pragma hdrstop cannot be inside an #if block" in VS C++?


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.


Solution

  • 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).