warning: passing argument 2 of ‘memset’ makes integer from pointer without a cast
然后我改变如下(使NulL为0)
Before Change : memset(key,NulL,KEY_BYTES);After Change : memset(key,KEY_BYTES);
警告已删除.
我正在使用linux& gcc编译器,C.
这是正确的行动吗?
解决方法 根据实现,C标准库有时将NulL定义为零整数(这将避免您看到的警告),但有时将NulL定义为零转换为voID指针.后一种实现会导致您看到的警告.要回答您的具体问题,在这种情况下您不应该使用NulL.无论实现如何,NulL都旨在用作空指针,而不是整数零的同义词.如果要使用memset用零填充内存块,则将零作为第二个参数传递,而不是NulL.
引自http://en.wikipedia.org/wiki/Stdlib.h:
总结NulL
The stdlib.h and stddef.h header files define
the macro NulL,which yIElds a null pointer
constant,and represents a pointer value that
is guaranteed not to point to a valID
address in memory.Variants
NulL may be defined as a
constant Expression equal to int zero,
long int zero,or zero cast to a voID
* pointer:#define NulL 0
#define NulL 0L
#define NulL ((voID *) 0)Although the null pointer constant is always represented in C by the symbolic constant 0 or by 0 cast to a voID pointer,the actual bit representation of such a pointer is system-specific and may contain one-bits.
以上是内存溢出为你收集整理的C memset警告全部内容,希望文章能够帮你解决C memset警告所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)