Error #include nested too deeply
转载:http://blog.csdn.net/ysdaniel/article/details/7043395
出现 Error #include nested too deeply 原因是:
头文件相互包含。
例如,一个工程中bsp.h 包含 LocDongle.h, LocDongle.h又包含bsp.h,
编译时就会报Error #include nested too deeply 。
解决办法:
1、将两个头文件共用的那一部分抽出来单独建一个头文件。
2、加预处理#ifndef.. #define...#endif
- //bsp.h
- #ifndef _BSP_H_
- #define _BSP_H_
- #include "LocDongle.h"
- #endif
- //LocDongle.h
- #ifndef _LOCDONGLE_H_
- #define _LOCDONGLE_H_
- #include "bsp.h"
- #endif
- <span style="font-family: simsun; line-height: 23px; "></span><pre><div><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">bsp.h</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 0); ">#ifndef _BSP_H_</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">文件开始、第一行</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 255); ">#define</span><span style="line-height: 18px; color: rgb(0, 0, 0); "> _BSP_H_</span><span style="line-height: 18px; color: rgb(0, 0, 0); ">
- #include </span><span style="line-height: 18px; color: rgb(128, 0, 0); ">"</span><span style="line-height: 18px; color: rgb(128, 0, 0); ">LocDongle.h</span><span style="line-height: 18px; color: rgb(128, 0, 0); ">"</span><span style="line-height: 18px; color: rgb(0, 0, 0); ">
- ...</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">内容,所有的函数声明等等放这里</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 255); ">#endif</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">文件末尾</span><span style="line-height: 18px; color: rgb(0, 0, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">LocDongle.h</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 0); ">#ifndef _LOCDONGLE_H_</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">文件开始、第一行</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 255); ">#define</span><span style="line-height: 18px; color: rgb(0, 0, 0); "> _LOCDONGLE_H_</span><span style="line-height: 18px; color: rgb(0, 0, 0); ">
- #include </span><span style="line-height: 18px; color: rgb(128, 0, 0); ">"</span><span style="line-height: 18px; color: rgb(128, 0, 0); ">bsp.h</span><span style="line-height: 18px; color: rgb(128, 0, 0); ">"</span><span style="line-height: 18px; color: rgb(0, 0, 0); ">
- ...</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">内容,所有的函数声明等等放这里</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span><span style="line-height: 18px; color: rgb(0, 0, 255); ">#endif</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 18px; color: rgb(0, 128, 0); ">文件末尾</span></div><div><span style="line-height: 18px; color: rgb(0, 128, 0); ">
- </span></div></pre><br>
- <p></p>
- <pre></pre>
- <br>
- <span style="font-family:simsun; font-size:14px; line-height:23px">头文件保护有用, 可以这样重复包含<br>
- 头文件包含其实就是在包含的位置展开它而已,<br>
- 你如果a.h包含了b.h<br>
- b.h又包含了a.h<br>
- 如果你使用了#ifndef.. #define...#endif的话<br>
- 你在一个.c文件中包含a.h那么它里面包含的b.h中包含的a.h将不会重复包含。</span><br>
- <p></p>
- <p><span style="font-family:simsun; font-size:14px; line-height:23px"><span style="font-family:simsun; font-size:14px; line-height:23px"><span style="font-family:simsun; font-size:14px; line-height:23px"><span style="font-family:simsun; font-size:14px; line-height:23px">头文件的嵌套一定要防止不断的包含,处于一个无限的循环!</span><br>
- </span></span></span></p>
Error #include nested too deeply的更多相关文章
- mac 安装 报错 "/usr/local/include/stdint.h:2:10: error: #include nested too deeply"
报错详细信息 构建错误 - “#include嵌套太深” /usr/local/include/stdint.h:2:10: error: #include nested too deeply #in ...
- Error getting nested result map values for 'company'. Cause: java.sql.SQLException: Invalid value for getInt() - 'NFHK188'
我今天遇到一个我不解的问题,是mybatis多对一关系查询出问题了,但是我自己还是解决了,在网上也查过那个错误,可是找不到我想要的.不知道你们遇到过没有,我接下来分享给大家.希望我这个第一篇博客能帮助 ...
- pip install py-stringsimjoin error: INCLUDE environment variable is empty
在用pip install py-stringsimjoin的时候报错error: INCLUDE environment variable is empty,后来在网上搜索下了说是需要下载安装VCF ...
- C语言中#ifdef,#ifndef和#endif的作用
现在规定一下头文件书写规范, 根据陈皓编写的跟我一起些makefile,一定要记住:头文件中应该只是声明,而定义应该放在C/C++文件中.否则如果出现有定义,比如头文件中有int a =2;如果有多个 ...
- gcc编译错误表
conversion from %s to %s not supported by iconv”iconv 不支持从 %s 到 %s 的转换” iconv_open”iconv_open” no ic ...
- 【翻译】R 中的设计模式
目录 R 中的设计模式 不动点算法 包装器模式 接口模式 柯里化(Currying) 闭包(Closures) 缓存模式 计数器模式 R 中的设计模式 本文翻译自 Design Patterns in ...
- System Error Codes
很明显,以下的文字来自微软MSDN 链接http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx M ...
- winerror.h中的内容(可以查看last error对应)
/************************************************************************* ** winerror.h -- error co ...
- pod出现include of non-modular header inside framework module 错误
今天打包pod 的时候 出现的错误 -> AFNetworking+RX (3.1.0.18) - ERROR | [iOS] xcodebuild: Returned an unsuccess ...
随机推荐
- 用.NET开发通用Windows App
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:随着Windows 10的正式发布,作为.NET开发人员应该开始或多或少了解一下通用( ...
- Dwz下拉菜单的二级联动
在DWZ文档中对组合框combox的是这样描述的: 在传统的select 用class 定义:class=”combox”, html 扩展:保留原有属性name, 增加了属性:ref. ref 属 ...
- mysql数据库备份与还原命令
还原一个数据库:mysql -h localhost -u root -p123456 www 备份一个数据库:mysqldump -h localhost -u root -p123456 www ...
- 关于解决haswell赛扬和奔腾 不能安装的问题
打开EFI\CLOVER\config.plist,并找到KernelAndKextPatches字段,在子集内插入下面代码. <key>FakeCPUID</key> < ...
- Liferay 6.2 改造系列之十七:当Portlet无权限时,不显示错误信息
在/portal-master/portal-impl/src/portal.properties文件中,有如下配置: # # Set this to true if users are shown ...
- 【HTML+CSS】七小时快速入门~~~~~~~
由于网络化的原因,学习很方便,但是也由于太方便了,学习资料很多会给刚想要入门却没有什么自制力的初学者造成困难,我自己来说学html和css先看了一本书,后来又辗转在慕课网.w3cschool等学习网站 ...
- express-9 Handlebars模板引擎(2)
视图和布局 视图通常表现为网站上的各个页面(它也可以表现为页面中AJAX局部加载的内容,或一封电子邮件,或页面上的任何东西).默认情况下,Express会在views子目录中查找视图.布局是一种特殊的 ...
- 对NLP的一些新认识
其实这是老板让上交的一份总结,贴出来,欢迎朋友们批评指正. 最近看了一部分关于NLP的几篇论文,其中大部分为神经网络实现, 从基本的HMM算法实现,到LSTM实现,有很多方法可以用来处理NLP任务中的 ...
- 微软开放WP开发者回复用户应用评论功能
1 4月18日,据The NextWeb网站报道,微软今天公布了一项新的开发者试点项目:回复Windows Phone应用评论.该公司表示,它们将在本周推出这项功能,不过目前仅对部分开发者开放. ...
- Android HttpClient post MultipartEntity - Android 上传文件
转自[http://blog.csdn.net/hellohaifei/article/details/9707089] 在Android 中使用HttpClient,MultipartEntity ...