C++ 'strcpy' gives a Warning (C4996)

前端 未结 9 1140
孤城傲影
孤城傲影 2020-12-03 08:15

I am getting this warning but all functions working properly .

what does this really means?

\'strcpy\': This function or variable may be unsafe. 
Con         


        
9条回答
  •  日久生厌
    2020-12-03 08:40

    use Secure Template Overloads or define wrapper functions not work for dynamically allocated buffers, so this attempt is futile.
    Either modify source to use secure replacement, or just ignore it.

    if the codes are writing by yourself, you had better change such strcpy to strcpy_s etc. if the modules are imported from trusted soures, you may choose to ignore the warning.

    ignore method 1: project globle scope: add _CRT_SECURE_NO_WARNINGS
    ignore method 2: ignore particular module: if only one or two of them, then you could simplely forbit warning for these modules when include them:

    #pragma warning(push)
    #pragma warning(disable: 4996)
    #include   //legacy module
    #include  //legacy module
    #pragma warning(pop)
    

提交回复
热议问题