implicit declaration of function 'asprintf' 警告的解决
来源:互联网 发布:grub windows引导丢失 编辑:程序博客网 时间:2024/06/14 13:35
asprintf使用起来非常方便,但是它是GNU扩展的C函数库,使用的时候经常会有如下警告:
warning: implicit declaration of function 'asprintf' [-Wimplicit-function-declaration]
调查发现asprintf的头文件是stdio.h,在该头文件中
#ifdef __USE_GNU/* Write formatted output to a string dynamically allocated with `malloc'. Store the address of the string in *PTR. */extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f, _G_va_list __arg) __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;extern int __asprintf (char **__restrict __ptr, __const char *__restrict __fmt, ...) __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;extern int asprintf (char **__restrict __ptr, __const char *__restrict __fmt, ...) __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;#endif
但是__USE_GNU是glibc内容的宏定义,我们不能在自己的代码中定义,因此要怎么解决呢?
解决方法:
在makefile中加入编译选项 -D_GNU_SOURCE
如果是用CMake,需加入add_definitions (-D_GNU_SOURCE)
如果遇到类似因#ifdef __USE_GNU引起的问题,可以通过如上设定尝试解决。
0 0
- implicit declaration of function 'asprintf' 警告的解决
- 解决:implicit declaration of function 警告
- 出现警告:implicit declaration of function
- 解决warning:implicit declaration of function 'Xil_Out32' [-Wimplicit-function-declaration]
- Xcode解决“Implicit declaration of function 'XXX' is invalid in C99” 警告或报错
- implicit declaration of function
- implicit declaration of function
- implicit declaration of function
- 编译时出现如下警告“implicit declaration of function Set_Disp_Port_SpeedMode"
- 警告 incompatible implicit declaration of built-in function ‘memset’ 解决方案
- implicit declaration of function '...' 的warning
- implicit declaration of function 's3c2410_gpio_cfgpin"的解决办法
- implicit declaration of function XXXXXXX 的warning
- implicit declaration of function ‘malloc’的解决方法
- implicit declaration of function 这种警告问题的原因及解决方法
- implicit declaration of function 这种警告问题的原因及解决方法
- xcode 中出现 Implicit declaration of function 'xxxx' is invalid in C99” 警告的解决办法
- Implicit declaration of function ‘xxxx’ is invalid in C99” 警告的解决办法
- JDBC数据库的连接
- (转载)一次Linux系统被攻击的分析过程
- CSS3 经典教程系列:CSS3 线性渐变(linear-gradient)
- AndroidStudio生成aar包
- mac 下配置ant和打包
- implicit declaration of function 'asprintf' 警告的解决
- 搭建EtherCAT通讯运动控制平台(二)升级到TwinCAT3
- XQuery
- 常见 core dump 原因分析signal 11 - SIGSEGV
- 什么是网络资源管理?
- 如何查找一个宏定义的位置
- #笔记#圣思园 JavaWeb 第29讲——Servlet
- DNS解析过程详解
- 浅谈php的缓存机制之redis