警告:'sizeof'的参数[-Werror = sizeof-pointer-memaccess]

时间:2018-06-06 05:06:06

标签: c warnings

使用gcc4.8.5编译时,我收到以下警告:

Boolean_t bsnap_isFileExtensionValid (const char *suffix)
{
    .......
    .......
    ......... 

    strncpy (gbsnapSuffix, suffix,/*sizeof MAXPATHLEN*/(suffix ));

}


 warning: argument to 'sizeof' in 'char* strncpy(char*, const char*, size_t)' call is the same expression as the source; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
         strncpy (gbsnapSuffix, suffix,sizeof(suffix ));

如何解决此类警告? 我是否需要禁用编译选项?

0 个答案:

没有答案