implicitly declaring library function'memcpy' with type 'void *怎么解决?
时间: 2023-12-26 22:05:32 浏览: 87
这个问题通常是因为你在代码中使用了 `memcpy` 函数,但是没有包含 `<string.h>` 头文件。要解决这个问题,你需要在代码中加入以下语句:
```c
#include <string.h>
```
这将包含 `<string.h>` 头文件,其中包含了 `memcpy` 函数的声明。这样编译器就能够正确地识别该函数,并将其编译到你的程序中。
相关问题
implicitly declaring library function
隐式声明库函数是指在程序中使用了某个库函数,但是没有在程序中显式地声明该函数。这种情况下,编译器会默认认为该函数已经被声明过,从而不会报错。但是,如果该函数的声明与实际定义不一致,就会导致程序出现错误。因此,为了避免这种情况的发生,我们应该在程序中显式地声明所有使用的库函数。
symbolic.c:58:3: warning:implicitlydeclaring libraryfunction 'memset' with type'void *(void *, int, unsigned ong)' [-Wimplicit-function-declaration]memset(arr,o,n); symbolic.c:58:3: note: include the header <string.h> or explicitly provide a declaration for 'memset'symbolic.c:106:5: warning: implicitly declaring libraryfunction 'memcpy' with type 'void *(void *, const void *unsigned Tong)' [-Wimplicit-function-declarationlmemcpy(arr, arr.5): symbolic.c:106:5: note: include the header <string.h> or explicitly provide a declaration for 'memcpy
这些warning的意思是在symbolic.c文件中,函数memset和memcpy被隐式声明并使用了,但没有在代码中显式声明。编译器建议你在代码中显式地包含<string.h>头文件,或者提供这些函数的声明。
你可以在代码中添加以下声明:
```
#include <string.h>
```
或者在代码中显式声明这些函数,例如:
```
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
```
这样应该就可以解决这些warning了。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)