从不同大小的整数转换为指针 [-Wint-to-pointer-cast]
好吧,我必须回顾一下之前在这里回答过的一个问题。由于其他原因我做了一些更改,现在又遇到问题了。以下是相关详细信息:
volatile char RxBuffer1[NEMA_BUFFER_LENGTH];
uint32_t NEMA_TypeStart;
char NEMA_Type[10];
uint32_t len;
...
memcpy(NEMA_Type,(const char*)RxBuffer1[NEMA_TypeStart], len);
通过演员表,我得到主题行中显示的错误。没有演员表我得到:
传递“memcpy”的参数 2 使指针来自不带 a 的整数 演员表
注意,如果我使用 strncpy 代替,也会发生同样的情况。所以我很困惑。我以为我明白 memcpy 使用 void* 。我做错了什么?
Well, I have to revive a question that was answered here before. I've made some changes for other reasons and now I have a problem again. Here is the relevant details:
volatile char RxBuffer1[NEMA_BUFFER_LENGTH];
uint32_t NEMA_TypeStart;
char NEMA_Type[10];
uint32_t len;
...
memcpy(NEMA_Type,(const char*)RxBuffer1[NEMA_TypeStart], len);
With the cast I get the error shown in the subject line. Without the cast I get:
passing argument 2 of 'memcpy' makes pointer from integer without a
cast
Note the same thing happens if I use strncpy instead. So I'm stumped. I thought I understood that memcpy uses void*. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将地址传递给
memcpy
。我假设你想要:You need to pass addresses to
memcpy
. I would assume you want:已经有一段时间了,但我认为你需要这样说......
你也可以说......
Its been awhile, but I think you need to say this instead...
You could also say...