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 ...
随机推荐
- PING命令入门详解
转自:http://www.linkwan.com/gb/tech/htm/928.htm 1.Ping的基础知识 ping命令相信大家已经再熟悉不过了,但是能把ping的功能发挥到最大的人却并不是很 ...
- SQLite密码添加移除
背景:电脑清理--个人洁癖 SQLite的最原始的是没有加密的,从而衍生了多种加密算法,但在平常使用中使用System.Data.Sqlite,但其加密后,一般都需要要单独的sqlite管理器--像我 ...
- 在Asp.Net MVC中PartialView与EditorFor和DisplayFor的区别
相同之处: PartialView, EditorFor 和 DisplayFor 都可以用作来实现页面的公共部分,其他页面可以根据需求来引用. 不同之处: PartialView 是从Page的角度 ...
- web2py学习之getting start环境搭建
一般如果做一个工程,可能需要ide,需要好的工具,web2py自包含了一个基于web的开发工具,但是并不算很好的编辑器 第二个可以使用的是pycharm,利用pycharm可以创建web2py的web ...
- C语言基本点初探
1,对于int a=10++;此语句错误,为什么呢,对于i++来说,i是一个变量,是把i加1然后赋值给i,然而10不是一个变量所以无法执行加加的语法; 2,运算符的优先级: 赋值运算符<逻辑运算 ...
- SQL2000/2005字符串拆分为列表通用函数
------------------------------------------------------------------ -- Author : htl258(Tony) -- Dat ...
- 梳理源码中 View 的工作原理
欢迎Follow我的GitHub, 关注我的掘金. 在View的工作过程中, 执行三大流程完成显示, 测量(measure)流程, 布局(layout)流程, 绘制(draw)流程. 从perform ...
- 关于Char类型数据做cout输出
当用cout 或者 printf()对char 或者 unsigned char类型数据进行输出的时候,默认输出的都是字符,而不是字符对应的数值.如果要输出数值,必须做int 类型数据的强制转换. 例 ...
- 使用Eclipse将Web项目打Jar包方法
1.对下载.安装和运行Eclipse,就不再说了: 2.找到待打包项目: 3.右键,Export-->Export: 4.选择,Jar: 5.按如图操作: 6.完成后:
- Laravel系列 目录结构
Where Is The Models Directory? app directory by default 其中 app:,core code of your application, almos ...