【发布时间】:2019-03-20 14:21:56
【问题描述】:
这段代码:
void Pack::packUInteger(void **buffer, unsigned int payload){
memcpy(*buffer, &payload, sizeof(unsigned int));
*buffer += sizeof(unsigned int);
}
产生这个警告,我想摆脱它而不告诉编译器忽略它:
src/messaging/Pack.cpp: In static member function ‘static void Pack::packUInteger(void**, unsigned int)’:
src/messaging/Pack.cpp:33:10: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
*buffer += sizeof(unsigned int);
~~~~~~~~^~~~~~~~~~
我知道它应该需要取消引用和强制转换,但我不知道如何正确地做到这一点。
感谢互联网! :)
【问题讨论】:
标签: c++ pointers void-pointers pointer-to-pointer