0

I'm trying to compile some rather trivial code in C++ and i keep getting "Warning: [FUNCTION] was declared deprecated"

Now this is on some of the more useful functions such as:

sprintf
strtok

why is this? Here is a sample of my code if you are interested:

if(IsChatting()){
            char chat[256];
            GetPendingChat(chat);
            char *token;
            token = strtok(chat," ");
            if(strcmp(token,"/bot")==0){
                token = strtok(NULL," ");
                if(token != NULL){
                    if(strcmp(token,"add")==0){
                        token = strtok(NULL," ");
                        if(token != NULL){
                            char msg[256];
                            sprintf(msg,"Attempting to enter bot with the name %s",token);
                            SendMessage(GetPlayerColour(GetLocalPlayerId()),msg);
                            //Enter(token);
                            SetChatting(false);
                            SetPendingChat("");
                        }
                        else{
                            SendMessage(GetPlayerColour(GetLocalPlayerId()),"SA:MP BOT: /bot add [name]");
                        }
                    }
                }
                else{
                    SendMessage(GetPlayerColour(GetLocalPlayerId()),"SA:MP BOT: /bot [add]");
                }
            }
        }

The exact warnings are:

Warning 2 warning C4996: 'strtok' was declared deprecated c:\documents and settings\will\my documents\visual studio 2005\projects\dllbot\dllbot\keyhook.h 10
Warning 3 warning C4996: 'strtok' was declared deprecated c:\documents and settings\will\my documents\visual studio 2005\projects\dllbot\dllbot\keyhook.h 12
Warning 4 warning C4996: 'strtok' was declared deprecated c:\documents and settings\will\my documents\visual studio 2005\projects\dllbot\dllbot\keyhook.h 15
Warning 5 warning C4996: 'sprintf' was declared deprecated c:\documents and settings\will\my documents\visual studio 2005\projects\dllbot\dllbot\keyhook.h 18

I'm using Visual Studio 2005

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Narue
0

>why is this?
Microsoft is pushing their "safe" (translation: cumbersome and completely non-portable) library. You can ignore those warnings because they're stupid and do nothing but clutter up your build. There are two ways to get rid of them. First, you can do it in your project settings under the "Disable Specific Warnings" option by adding 4996. Second, you can use a pragma in your source code:

#pragma warning(disable:4996)

The former is much better because it doesn't alter the source.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.