Jump to content
  • Advertisement
Sign in to follow this  

'lstrcpy': marked as #pragma deprecated

This topic is 4884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, Been having some fun trying to compile a project that I haven't touched in a couple of months. Problem is that I've installed both XP-SP2 and DX9 Dec04 Update since I last looked at it. One of my files now generates a nice long list of:
Quote:
atlbase.h(3685) : warning C4995: 'lstrcpy': name was marked as #pragma deprecated atlbase.h(3685) : warning C4995: 'lstrcpyA': name was marked as #pragma deprecated atlbase.h(5994) : warning C4995: 'lstrcat': name was marked as #pragma deprecated atlbase.h(5994) : warning C4995: 'lstrcatA': name was marked as #pragma deprecated CAudio.cpp(281) : warning C4995: 'wsprintf': name was marked as #pragma deprecated CAudio.cpp(281) : warning C4995: 'wsprintfA': name was marked as #pragma deprecated
To be honest, I'm at a bit of a loss as to why its doing this and as a consequence how to go about fixing it... I vaguely remember reading something about DX9 now being more strictly coupled with the platform SDK but the search feature is disabled so I cant try and find that again. Could the above errors be caused by updating the DX sdk? given that the parts it complains about are from the platformSDK shipped as part of my VC7 installation. Any ideas are greatly appreciated! Cheers, Jack

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jollyjeffers
To be honest, I'm at a bit of a loss as to why its doing this and as a consequence how to go about fixing it...


Because the functions have been marked as deprecated. The first thing I would do is check the documentation to see what functions they suggest to replace them with. Barring that, examine the header files, there may be comments in there.

Quote:
I vaguely remember reading something about DX9 now being more strictly coupled with the platform SDK but the search feature is disabled so I cant try and find that again.


Google?

Quote:
Could the above errors be caused by updating the DX sdk? given that the parts it complains about are from the platformSDK shipped as part of my VC7 installation.


Yes, it is possible.

Share this post


Link to post
Share on other sites
Thanks for the quick reply! rating++[smile]

Quote:
Because the functions have been marked as deprecated. The first thing I would do is check the documentation to see what functions they suggest to replace them with. Barring that, examine the header files, there may be comments in there.

I get the bit about deprecation, just not the bit as to why it worked fine a couple of months back and doesn't now. The only things that have changed shouldn't have affected 'atlbase.h'...

There aren't any comments in the header file, except some about disabling the warnings that I'm getting [rolleyes].

Google doesn't seem to be too good at indexing these forums, and it didn't come with any meaningful solutions when I did a "google groups" or plain google search.

However, I have come to one possible reason... All of the lstrcat type things are aliases for lstrcatA or lstrcatW depending on whether unicode is being used. I'll be guessing that its trying to tell my program to use unicode (which I thought I was) and/or atlbase.h is somehow still trying to reference the non-unicode version.

Yet, at the same time, my code never uses ANY of the functions it warns about - its the internal system/api headers that do.

Jack

Share this post


Link to post
Share on other sites
There's a whole list of api's like this that are marked as deprecated because they're error prone. In particular lstrcpy doesn't have a parameter describing the size of the destination buffer so it will happily overwrite the end if you give it a source string that is to big.

From the MSDN entry for lstrcpy

Security Alert Using this function incorrectly can compromise the security of your application. The first argument, lpString1, must be large enough to hold lpString2 and the closing '\0', otherwise a buffer overrun may occur. Buffer overruns may lead to a denial of service attack against the application if an access violation occurs. In the worst case, a buffer overrun may allow an attacker to inject executable code into your process, especially if lpString1 is a stack-based buffer. Consider using one of the following alternatives: StringCbCopy, StringCbCopyEx, StringCbCopyN, StringCbCopyNEx, StringCchCopy, StringCchCopyEx, StringCchCopyN, or StringCchCopyNEx. You should review Security Considerations: Windows User Interface before continuing.

Share this post


Link to post
Share on other sites
Quote:
There's a whole list of api's like this that are marked as deprecated because they're error prone.

Makes sense.

However, I'm still at a bit of a loss as to solving it - as mentioned, no where in my project do I use the functions the compiler warns of. I'd guess I need to update the platformSDK (or something), but I'd like to be sure first - I can easily see myself creating a whole lot of extra work for no reward [smile]

Jack

Share this post


Link to post
Share on other sites
I just spent the last 30mins updating the platformSDK using MS's nifty little web-update tool. Seems like most of my warnings have disappeared now, which is good.

Thanks for the help though,
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!