[C++] does not name a type
从网上找到了以下几点 https://blog.csdn.net/fly20180712/article/details/88306008
1、没有加调用函数的头文件
2、不存在xxx命名空间
3、包含头文件,但是调用的时候,类名写错了
但是我睁大了眼睛也没看到错误在哪里,直到后来注意到我似乎出现了循环定义。
有两个文件,一个类 一个结构体结构如下
log.h
#include "Squeue.h"
struct event_info{
int fd;
Squeue q;
};
Squeue.h
...
#include "log.h"
class Squeue{
event_info* ei;
public:
int push(char* src,int len){
...
ei->q->push(...);
...
}
};
...
上面出现的问题就是,event_info结构体中用到了Squeue类,但是同时Squeue也用到了event_info结构体
这样就会出现环形定义的情况,会出现does not name a type的错误。
但是根据提示根本不知道问题是什么,直到我注意到了环形定义。然后在结构体定义的上面写上了class Squeue; 向前声明。然后错误变化了,变成了"field has incomplete type"。
通过查询这个错误,找到了这个博客
https://blog.csdn.net/smcnjyddx0623/article/details/51736195
找到了解决方法,就是把上面结构体中的 Squeue q;改成 Squeue *q; 当然,还需要修改对应的代码,把 q.push()修改成q->push()
原因是因为在定义结构体event_info的时候,还没有编译到Squeue,此时编译器还不知道Squeue的内部状况。所以不能直接声明本体,只能声明指针。
[C++] does not name a type的更多相关文章
- salesforce 零基础学习(六十二)获取sObject中类型为Picklist的field values(含record type)
本篇引用以下三个链接: http://www.tgerm.com/2012/01/recordtype-specific-picklist-values.html?m=1 https://github ...
- AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...
- $.type 怎么精确判断对象类型的 --(源码学习2)
目标: var a = [1,2,3]; console.log(typeof a); //->object console.log($.type(a)); //->ar ...
- input type='file'上传控件假样式
采用bootstrap框架样式 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...
- mount报错: you must specify the filesystem type
在linux mount /dev/vdb 到 /home 分区时报错: # mount /dev/vdb /homemount: you must specify the filesystem ty ...
- error C4430:missing type specifier 解决错误
错误 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...
- The type javax.ws.rs.core.MediaType cannot be resolved. It is indirectly referenced from required .class files
看到了http://stackoverflow.com/questions/5547162/eclipse-error-indirectly-referenced-from-required-clas ...
- OpenCASCADE Ring Type Spring Modeling
OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...
- <input type="file">上传文件并添加路径到数据库
注:这里是用的mvc所以没法用控件 html代码 <form method="post" enctype="multipart/form-data"> ...
- html中,文件上传时使用的<input type="file">的样式自定义
Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...
随机推荐
- css3文字阴影和盒子阴影
文字阴影 文字阴影的语法格式: text-shadow:水平向右的偏移值 向下的偏移值 迷糊度 阴影的颜色,水平向右的偏移值 向下的偏移值 迷糊度 阴影的颜色; 可以有多个阴影,但是在实际的项目中最多 ...
- 火狐谷歌浏览器去掉input type=number时控件的方法
html 默认:<input type="number" /></br> 处理:<input type="number" clas ...
- 加速tortoisegit的show log,减少等待时间
KMSID: 81703 是否同步到KM: 是 是否原创: 是 标签: 游戏开发 允许复制: 是 允许评论: 是 允许导出PDF: 是 职业库分类KMS: 游戏-游戏程序 查看权限KMS:网易正式员工 ...
- clion运行单个c和c++文件(.c.cpp)
运行方法 在clion中安装插件:C/C++Single File Execution 在要执行的cpp文件中添加main函数 在cpp文件的编辑器界面中点右键会出现[Add executable f ...
- 从嘉手札<2024-1-10.2>
我们每个人都是在受挫中成长起来的 你不能剥夺他人在受苦中获益的权利 大部分人对吃苦的含义可能理解的太肤浅了 穷并不是吃苦 吃苦的本质是长时间为了某个目标而聚焦的能力 在这个过程中放弃娱乐生活.放弃无效 ...
- HS_xh 诗选
@HS_xh 给我以火,给我以火!!! 我将在烈火中永生,囚歌写的时候人家还没出生,诶6年后就死了是吧,啊那人家都快死了,诶你怎么死了 你能不能凑齐十个一起发 胡适于 1920 发表了中国第一部白话诗 ...
- 物联网浏览器(IoTBrowser)-Modbus协议集成和测试
Modbus协议在应用中一般用来与PLC或者其他硬件设备通讯,Modbus集成到IoTBrowser使用串口插件模式开发,不同的是采用命令函数,具体可以参考前面几篇文章.目前示例实现了Modbus-R ...
- 从浏览器原理出发聊聊 Chrome 插件
浏览器架构演进 单进程浏览器时代 单进程浏览器是指浏览器的所有功能模块都是运行在同一个进程里,这些模块包含了网络.插件.JavaScript 运行环境.渲染引擎和页面等.在 2007 年之前,市面上浏 ...
- Delphi判断一个字符串在另一个字符串中出现的次数 7个方法的效率对比。
unit Unit14; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syste ...
- 利用ogg实现oracle到kafka的增量数据实时同步
前言 ogg即Oracle GoldenGate是Oracle的同步工具,本文讲如何配置ogg以实现Oracle数据库增量数据实时同步到kafka中,其中同步消息格式为json. 下面是我的源端和目标 ...