从网上找到了以下几点 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的更多相关文章

  1. salesforce 零基础学习(六十二)获取sObject中类型为Picklist的field values(含record type)

    本篇引用以下三个链接: http://www.tgerm.com/2012/01/recordtype-specific-picklist-values.html?m=1 https://github ...

  2. 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 ...

  3. $.type 怎么精确判断对象类型的 --(源码学习2)

    目标:  var a = [1,2,3];     console.log(typeof a); //->object     console.log($.type(a)); //->ar ...

  4. input type='file'上传控件假样式

    采用bootstrap框架样式 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...

  5. mount报错: you must specify the filesystem type

    在linux mount /dev/vdb 到 /home 分区时报错: # mount /dev/vdb /homemount: you must specify the filesystem ty ...

  6. error C4430:missing type specifier 解决错误

    错误    3    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...

  7. 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 ...

  8. OpenCASCADE Ring Type Spring Modeling

    OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...

  9. <input type="file">上传文件并添加路径到数据库

    注:这里是用的mvc所以没法用控件 html代码 <form method="post" enctype="multipart/form-data"> ...

  10. html中,文件上传时使用的<input type="file">的样式自定义

    Web页面中,在需要上传文件时基本都会用到<input type="file">元素,它的默认样式: chrome下: IE下: 不管是上面哪种,样式都比较简单,和很多 ...

随机推荐

  1. 【JS 逆向百例】拉勾网爬虫,traceparent、__lg_stoken__、X-S-HEADER 等参数分析

    关注微信公众号:K哥爬虫,持续分享爬虫进阶.JS/安卓逆向等技术干货! 声明 本文章中所有内容仅供学习交流,抓包内容.敏感网址.数据接口均已做脱敏处理,严禁用于商业用途和非法用途,否则由此产生的一切后 ...

  2. golang uuid库介绍

    简介: 在现代软件开发中,全球唯一标识符(UUID)在许多场景中发挥着重要的作用.UUID是一种128位的唯一标识符,它能够保证在全球范围内不重复.在Go语言中,我们可以使用第三方库github.co ...

  3. Go - 基本数据类型和其字符串表示之间转换

    1. 基本数据类型和其字符串表示之间转换 基本类型的值,都有一个字符串表示,如数字类型值1 字符串表示为 "1",字符的编码为Unicode或者UTF-8,数字的编码是 int,底 ...

  4. Python自动化办公--Pandas玩转Excel数据分析【三】

    相关文章: Python自动化办公--Pandas玩转Excel[一] Python自动化办公--Pandas玩转Excel数据分析[二] python处理Excel实现自动化办公教学(含实战)[一] ...

  5. 5.1 C++ STL 集合数据容器

    Set/Multiset 集合使用的是红黑树的平衡二叉检索树的数据结构,来组织泛化的元素数据,通常来说红黑树根节点每次只能衍生出两个子节点,左面的节点是小于根节点的数据集合,右面的节点是大于根节点的集 ...

  6. C++ Boost 内存池与智能指针

    Pool内存池: 只能开辟常规内存,数据类型为int,float,double,string等. #include <iostream> #include <boost/pool/p ...

  7. C/C++ Qt 命令行版网络通信

    通常情况下Qt如果需要建立网络通信则必须依附于图形界面,但如果是新手入门,图形界面则显得太过于繁琐不利于学习原理,如下本人实现了命令行版本的网络通信案例,能够让读者更好的理解Qt是如何创建网络通信套接 ...

  8. Python实现栈、队列、双端队列

    栈的实现 class Stack(): def __init__(self): self.items = [] def push(self, item): self.items.append(item ...

  9. JVM(Java虚拟机)整理(二)

    前言 上一篇内容:JVM(Java虚拟机)整理(一)https://www.cnblogs.com/xiegongzi/p/17994659 Java 内存模型(JMM) Java 内存模型引入 声明 ...

  10. Hive-分区取TOP N问题

    问题背景 设想你对用户在不同品类上的行为打分聚合后得到这样一个表 user_cate_score uid cate score 1 1 0.3 2 2 0.5 8 3 0.9 现在,你想将每个品类的T ...