1、warning: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
在使用memset时,传参传的是一个char * argument,但是在memset中使用sizeof()时,直接使用了sizeof(argument),因为这是一个指针,所以永远是使用sizeof()永远是4个字节,应该使用的是sizeof(*argument)
2、warning: null argument where non-null required (argument 2) [-Wnonnull]
(1)、 strcpy( g_detRes.m_ttc_tp ,NULL);
set the first argument to a NULL pointer
(2)、 strcpy( g_detRes.m_ttc_tp ,“NULL”); set the first argument to a NULL string
本文解析了编程中遇到的两种常见警告:一是使用memset时,因sizeof指针而非其指向内容导致的问题;二是strcpy调用时传入空指针引发的警告。针对这两种情况提供了具体的代码示例和修正建议。
9852

被折叠的 条评论
为什么被折叠?



