《C程序设计语言》示例报错“conflicting types for ‘getline’”勘误
来源:互联网 发布:大数据 企业管理 编辑:程序博客网 时间:2024/06/05 00:41
手动跑C语言“圣经”《C程序设计语言》(https://book.douban.com/subject/1139336/)自带的例子(P21页)时,编译竟然报错,一脸懵逼。
1_9.c:7:5: error: conflicting types for ‘getline’ int getline(char line[], int maxline); ^In file included from 1_9.c:1:0:/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here extern _IO_ssize_t getline (char **__restrict __lineptr, ^1_9.c:31:5: error: conflicting types for ‘getline’ int getline(char s[], int lim) ^In file included from 1_9.c:1:0:/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here extern _IO_ssize_t getline (char **__restrict __lineptr, ^
看一下报错,是和“ /usr/include/ ”下的C标准库“ stdio.h ”有冲突,该文件也声明定义了“ getline ”。
所以,把原书示例中的“ getline ”函数换一下名字就OK了,编译成功。书的内容是有点老了!
root@ubuntu:~/c# gcc -o 1_9 1_9.c root@ubuntu:~/c# ./1_9 < 1_9.c for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
阅读全文
0 0
- 《C程序设计语言》示例报错“conflicting types for ‘getline’”勘误
- error: conflicting types for ‘getline’
- Spec2006 编译错误 md5sum.c: conflicting types for 'getline'
- Xcode编译报错: Conflicting types for 'areIntsDifferentt' Conflicting types for 'boolString'
- error: conflicting types for 'memcpy' 类似报错解决方法
- C语言“conflicting types for ...” 错误
- conflicting types for 'wchar_t'
- conflicting types for ...
- conflicting types for。。。。。。
- error: conflicting types for 'XXXX'
- conflicting types for xx错误
- error: conflicting types for 'XXXX'
- conflicting types for xx错误
- conflicting types for xx错误
- conflicting types for xx错误
- error: conflicting types for 'RTASSERTVAR'
- conflicting types for 'timer_t' 的解决
- 好文章error: conflicting types for 'urlencode'
- 第一个错误的代码版本
- 大整数运算库gmp安装及使用
- 自动化测试工具 Selenium WebDriver 入门教程
- Java POI导出Word文档
- java语言基础(74)——多维集合的存储和遍历
- 《C程序设计语言》示例报错“conflicting types for ‘getline’”勘误
- 新手看php手册的正确姿势
- java单例
- pacemaker配置Apache服务
- java内部类
- 【Unity】Unity自带卡通shader(toon shader)分析(一)
- Android_Fragment碎片
- 机器学习工程实践方法论
- Kotlin-08.类和继承(class/Inheritance)