   [C++] Visual Studio and _SECURE_SCL
  Perhaps I don't fully understand what the _SECURE_SCL #define does, but I stumbled across something today that has me confused.  I was able to distill the problem down to this snippet of code.#include <iostream>#include <vector>#ifdef _SECURE_SCL#undef _SECURE_SCL#endif#define _SECURE_SCL 0#include <queue>int main(int argc, char* argv[]){    std::queue<int> q;    q.push(5);    int printQ = q.front();    std::cout << "The value is: " << printQ << std::endl;    std::vector<int> v;    v.push_back(5);    int printV = v.front();    std::cout << "The value is: " << printV << std::endl;return 0;}Compiling the above under Visual Studio 2008 SP 1 gives the following errors:1>c:\program files\microsoft visual studio 9.0\vc\include\deque(108) : error C2248: 'std::deque<_Ty>::_Myoff' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1309) : see declaration of 'std::deque<_Ty>::_Myoff'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(103) : while compiling class template member function 'const int &std::_Deque_const_iterator<_Ty,_Alloc,_Secure_validation>::operator *(void) const'1>   with1>   [1>  _Ty=int,1>  _Alloc=std::allocator<int>,1>  _Secure_validation=true1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(340) : see reference to class template instantiation 'std::_Deque_const_iterator<_Ty,_Alloc,_Secure_validation>' being compiled1>   with1>   [1>  _Ty=int,1>  _Alloc=std::allocator<int>,1>  _Secure_validation=true1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(780) : see reference to class template instantiation 'std::_Deque_iterator<_Ty,_Alloc,_Secure_validation>' being compiled1>   with1>   [1>  _Ty=int,1>  _Alloc=std::allocator<int>,1>  _Secure_validation=true1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(779) : while compiling class template member function 'int &std::deque<_Ty>::front(void)'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\queue(24) : see reference to class template instantiation 'std::deque<_Ty>' being compiled1>   with1>   [1>  _Ty=int1>   ]1>   c:\projects\test\genericmailboxtest\genericmailboxtest\genericmailboxtest.cpp(14) : see reference to class template instantiation 'std::queue<_Ty>' being compiled1>   with1>   [1>  _Ty=int1>   ]1>c:\program files\microsoft visual studio 9.0\vc\include\deque(109) : error C2248: 'std::deque<_Ty>::_Myoff' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1309) : see declaration of 'std::deque<_Ty>::_Myoff'1>   with1>   [1>  _Ty=int1>   ]1>c:\program files\microsoft visual studio 9.0\vc\include\deque(109) : error C2248: 'std::deque<_Ty>::_Mysize' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1310) : see declaration of 'std::deque<_Ty>::_Mysize'1>   with1>   [1>  _Ty=int1>   ]1>c:\program files\microsoft visual studio 9.0\vc\include\deque(114) : error C2248: 'std::deque<_Ty>::_Mapsize' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1308) : see declaration of 'std::deque<_Ty>::_Mapsize'1>   with1>   [1>  _Ty=int1>   ]1>c:\program files\microsoft visual studio 9.0\vc\include\deque(115) : error C2248: 'std::deque<_Ty>::_Mapsize' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1308) : see declaration of 'std::deque<_Ty>::_Mapsize'1>   with1>   [1>  _Ty=int1>   ]1>c:\program files\microsoft visual studio 9.0\vc\include\deque(116) : error C2248: 'std::deque<_Ty>::_Map' : cannot access protected member declared in class 'std::deque<_Ty>'1>   with1>   [1>  _Ty=int1>   ]1>   c:\program files\microsoft visual studio 9.0\vc\include\deque(1307) : see declaration of 'std::deque<_Ty>::_Map'1>   with1>   [1>  _Ty=int1>   ]There is a list of things I can do to make it so the error does not occur. 1. Don't set _SECURE_SCL to 0. 2. Swap the #include locations of <queue> and <vector>. 3. Don't call front() on the std::queue.  (I can call push()/pop() all I want, though).I'm really just not sure what the root meaning behind the given error is.  Can anyone give some insight?  Thanks.   
  If you define _SECURE_SCL you need to do it before *all* header files, or  preferably in the project properties rather than a source file.   ;  _SECURE_SCL is meant to be a project-wide setting. It affects the interpretation of standard library header files. A project that mixes and matches "secure" and "insecure" containers is extremely unlikely to work properly, and there is no particular reason for wanting to do things that way anyway. The point of _SECURE_SCL is to allow you to do debugging - across the entire project - at the cost of (quite a bit of it, potentially) performance.Therefore... like no such user said.   ;  Noted.  Thanks for the input.The source for my post was an example that took a while to distill down.  I originally thought I was tracking a template class inheritance problem until it all boiled down to my example.  Someone had tried defining _SECURE_SCL 0 at the top of what he thought was a top-level header file.  Obviously it wasn't.  My confusion stemmed from the errors the compiler actually spat out, which are pretty misleading to me.  Thanks for the help guys.   