the error C4996 problems on the wxwidgets 3.2.1 with Visual Studio 2022

234 views
Skip to first unread message

Ehlo Guan

unread,
Jun 6, 2023, 6:48:54 AM6/6/23
to wx-dev
To whom it may concern:
      thanks for reading the message, I'm using the wxwidgets in c++. Now I got the problem of the error C4996 like
       C4996 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
when I start to write my project, the error didn't occurred. But when things keep going, the error occurs. I write the wxApp class with "MyApp.h" and "MyApp.cpp", and I wrote a lots of the static functions and Variables in the myapp class. will it lead to the problems? btw these function and Variables I also used in dialogs or ui. here is the example of my "cameraDialog.cpp"
``` 
#include "CameraTestDialog.h"
#include "MyApp.h"
string CameraTestDialog::getSolutionId(string solutionNameValue) {
    sqlCmd = "Select SolutionId from solutionInfos where SolutionName=\"";
    //sqlCmd += MyApp::GbkToUtf8(SolutionChoice->GetStringSelection().ToStdString().c_str()) + "\";";
    sqlCmd += MyApp::GbkToUtf8(solutionNameValue.c_str()) + "\";";
    //sqlCmd += solutionParams->changedToSolution + "\";";
    string solutionId = cameraTestSql->SelectData(sqlCmd.c_str(), 1, msg);
    if (solutionId != "") return MyApp::Split(solutionId, "\x5")[0];
    else return solutionId;
}
```
how can I solve the problems. Now I use the _CRT_SECURE_NO_WARNINGS to let my work go on. But still I need to solve this.
thanks for your help.

Vadim Zeitlin

unread,
Jun 6, 2023, 9:11:13 AM6/6/23
to wx-...@googlegroups.com
On Mon, 5 Jun 2023 23:15:12 -0700 (PDT) Ehlo Guan wrote:

EG> I'm using the wxwidgets in c++. Now I got the problem of the error
EG> C4996 like
EG> C4996 'strncat': This function or variable may be unsafe.

Hello,

Please notice that C4996 is not an error, but a warning (and of the least
important C4xxx category, at that), so in the worst case you can just
ignore it.

EG> when I start to write my project, the error didn't occurred. But when
EG> things keep going, the error occurs. I write the wxApp class with "MyApp.h"
EG> and "MyApp.cpp", and I wrote a lots of the static functions and Variables
EG> in the myapp class. will it lead to the problems?

No, absolutely not. But you do need to understand where exactly is this
warning given. You won't see this if you only look at the "Errors" window
in MSVS, but you can open the "Output" window to see where exactly it
happens.

Good luck,
VZ
Reply all
Reply to author
Forward
0 new messages