invalid conversion from 'uint16_t*' {aka 'short unsigned int*'} to 'uint16_t' {aka 'short unsigned int'} [-fpermissive]
时间: 2024-04-17 10:29:53 浏览: 111
这个错误提示表明在代码中存在类型不匹配的问题。具体来说,将一个 `uint16_t*`(指向 `uint16_t` 类型的指针)转换为 `uint16_t`(`uint16_t` 类型)时发生了错误。
要解决这个问题,你可以检查以下几点:
1. 确保你的代码中的变量声明和使用的类型是一致的。例如,如果你需要使用 `uint16_t` 类型的值,就应该使用 `uint16_t` 类型的变量,而不是指向 `uint16_t` 的指针。
2. 如果你确实需要使用指针,而不是值,那么你需要使用解引用操作符 `*` 来获取指针指向的值。例如,如果你有一个 `uint16_t*` 类型的指针 `ptr`,你可以通过 `*ptr` 来获取指针指向的 `uint16_t` 值。
3. 如果你在函数调用或赋值语句中出现了类型不匹配的问题,你可能需要进行相应的类型转换。在 C/C++ 中,可以使用类型转换操作符来将一个类型转换为另一个类型。例如,可以使用 `(uint16_t)` 来将一个值转换为 `uint16_t` 类型。
请根据你的具体代码和需求检查并修正类型不匹配的问题。如果你能提供更多的代码片段或上下文信息,我可以给出更具体的帮助。
相关问题
invalid conversion from ‘pthread_t {aka long unsigned int}’ to ‘pthread_t* {aka long unsigned int*}’是怎么回事
这个错误通常发生在将一个 pthread_t 类型的值赋值给一个 pthread_t 指针的时候。pthread_t 是一个不透明的数据类型,实际上是一个整数,而不是一个指针类型。因此,将 pthread_t 类型的值直接赋值给 pthread_t 指针是错误的。
举个例子,如果有如下代码:
```
pthread_t tid;
pthread_create(&tid, NULL, thread_func, NULL);
pthread_join(tid, NULL);
```
上述代码中,pthread_create() 函数的第一个参数是一个指向 pthread_t 类型变量的指针,而不是 pthread_t 类型本身。因此,如果将上述代码中的 &tid 改为 tid,就会出现上述错误。
你需要将代码中的指针类型改为非指针类型,或者将指针类型的变量改为指针类型的指针。
error: invalid conversion from ‘char*’ to ‘volatile uint8_t* {aka volatile unsigned char*}’ [-fpermissive]
这个错误提示表明,你尝试将一个char类型的指针转换为volatile uint8_t类型的指针,但是这样的转换是不合法的。因为char类型的指针和uint8_t类型的指针虽然都是指针类型,但是它们实际上指向的数据类型是不同的,不能直接进行转换。
如果你需要将一个char类型的指针转换为volatile uint8_t类型的指针,可以使用类型转换运算符进行强制类型转换,例如:
```
char* str = "hello";
volatile uint8_t* ptr = reinterpret_cast<volatile uint8_t*>(str);
```
在这个示例中,我们使用了reinterpret_cast运算符将char类型的指针str强制转换为volatile uint8_t类型的指针ptr。需要注意的是,这样的转换可能会导致指针指向非法的内存地址,因此需要谨慎使用。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)