您的位置:首页 > 移动开发 > Android开发

使用GCC4.8 编译android内核提示warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’

2013-10-14 22:45 1271 查看
完整的warning为:

warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’ call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]


解决方法,参考:

http://gcc.gnu.org/gcc-4.8/porting_to.html

方法1:

#include <string.h>

struct A { };

int main(void)
{
A obj;
A* p1 = &obj;
A p2[10];

memset(p1, 0, sizeof(p1)); // error
memset(p1, 0, sizeof(*p1)); // ok, dereferenced
memset(p2, 0, sizeof(p2)); // ok, array

return 0;
}


方法2:

在Makefile添加:

KBUILD_CFLAGS   += -Wno-sizeof-pointer-memaccess
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: