View Full Version : Request for sticky

05-07-2006, 06:21 PM
Before we get inundated with threads stating the C++ standard library and C standard library functions are deprecated due to MSVC .NET 2005's error reporting, we should create sticky threads at the top of the forums addressing these very issues.

The C/C++ standard library is not deprecated as MS says it is.

05-07-2006, 07:22 PM
What exactly about the STL is deprecated?

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
vector<string> vstrLst;
string test;
test = "bob";

vector<string>::iterator vstrIter;

vstrIter = vstrLst.begin();

while (vstrIter != vstrLst.end())
cout << *vstrIter << endl;

return 0;

That compiles without a hitch in 2005.

Ken Fitlike
05-07-2006, 07:59 PM
//#define _SECURE_SCL 0

#include <iostream>
#include <string>
#include <vector>

int main()
std::string source("It might be ugly but at least it's standard!");

std::size_t length=source.length();

std::vector<char> target(length+1,'\0');

//msvc2005 says std::string::copy 'deprecated'. Unless _SECURE_SCL is
//#defined as zero
source.copy(&target[0],length); //(<---msvc2005 say OUCH)

Which, with msvc2005 gives rise to:

warning C4996: 'std::basic_string<_Elem,_Traits,_Ax>::copy' was declared deprecated
If you uncomment the msvc2005 specific preprocessor definition in the example above and recompile it with msvc2005 it magically becomes 'standard' again, losing the warning. Obviously, with a real compiler (http://cboard.cprogramming.com/showthread.php?t=78881) ( :p ;) ) like MinGW this isn't an issue.

So, what msvc2005 means by 'standard' in this context has little to do with the C++ standard but everything to do with an ms specific extension - and this, sadly, is default behaviour for msvc2005.

However, with a warning like that, a beginner who's new to c++ will understandly probably believe the warning and think that std::string::copy is, in fact, deprecated.

I don't believe this is good - and I second Bubba's excellent suggestion that before the mad rush of 'msvc2005 tells me it's wrong so it must be' posts really starts in earnest we have something in place to deal with it.

Read this thread (http://cboard.cprogramming.com/showthread.php?t=78889) for more details - in particular follow up some of the links posted there to read objections made by smarter people than me regarding why this tactic of microsoft's is potentially more than just a transient annoyance.

05-07-2006, 08:03 PM
mment the msvc2005 specific preprocessor definition in the example above and recompile it with msvc2005 it magically becomes 'standard' again, losing the warning. Obviously, with a real compiler (http://cboard.cprogramming.com/showthread.php?t=78881) ( :p ;) ) like MinGW this isn't an issue.
Real windows compiler. ;) Seriously, if you plan on writing windows code and want full access to all things windows you're forced to use visual studio, heh. I'm not saying it's a good thing, but it's just something we've got to deal with until some underdog compiler comes around.

So in the end, valid point. I just wasn't sure what kind of code was causing this problem.

And to clarify, I've evidently been out of the loop way too long as far as compilers as the name ming was unfamiliar to me, haha. *shakes head and explodes*

05-07-2006, 09:03 PM
>>*shakes head and explodes*

I just had a lemmings flashback :D

This is definitely good to know if/when I get 2005 (still using VS 2003)

Edit: After reading about this C++/CLI crap, all I can say is yuck. I think they're trying to kill C++! Does this remind anyone else of C#? I haven't worked with it a lot, but some of this C++/CLI stuff seems eerily similar.

05-09-2006, 09:25 AM
If Microsoft really wanted C# to catch on, they would have to make it more platform and compiler-independant. For example, I don't use C# nor will I ever because I'm using a Mac. And even if I did switch back to Windows, I would still use C++ to keep my code portable. As long as Microsoft keeps C# proprietary, it's not going to catch on like C/C++ and Java did.

Even if they do "try to deprecate" C++, they can't kill it!

05-09-2006, 03:29 PM
Let's wait until/if it becomes a problem before creating _another_ sticky.

05-09-2006, 08:13 PM

yeah, I'm with Sang here... don't want a whole big long list of stickies again...

05-10-2006, 02:20 AM

Just trying to be a bit pro-active. Mark my word these types of threads will pop up more and more as everyone switches to .NET 2005. The help file confuses C++ and CLI so much and makes the line between them so thin, an inexperienced programmer may make the false assumption that Microsoft CLI and/or Microsoft extensions to C++ are actually part of the standard.

And with Microsoft pressing for standardization of their CLI I look for them to attempt to hijack C/C++, although at the present it does look like there are a great many opponents to CLI being mixed with C++.