从网上找到了以下几点 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. Ant Design Vue表单验证失败

    表单验证遇见的坑 01 如果你受控数据是这样写的话 const formState= reactive({ youForm:{ youNaNe:'', useSlectValue: '001', da ...

  2. pycharm像vs那样进行代码折叠

    在visual studio中可以使用#region和#endregion来进行代码折叠,我尝试在pycharm中也可以使用相同的指令来折叠代码. 但是如果#endregion是在方法的最后面或者类的 ...

  3. 手把手教学构建证券知识图谱/知识库(含码源):网页获取信息、设计图谱、Cypher查询、Neo4j关系可视化展示

    手把手教学构建证券知识图谱/知识库(含码源):网页获取信息.设计图谱.Cypher查询.Neo4j关系可视化展示 demo展示: 代码结构 stock-knowledge-graph/ ├── __i ...

  4. 关于JAVA泛型数组类型擦除引发的问题及解决方案

    先看如下一个DEMO示例代码:(其中doBatchGet被子类重写了1次) public abstract class BaseDemoService<T> { public String ...

  5. 聚石塔的K8s 容器服务使用注意事项,坑的总结

    1. 首先聚石塔是不能使用 8080 端口的,会审核不通过. 2.然而,容器服务默认的却是8080,最彻底的解决方法就是修改成80,注意3个地方: 以上3个地方要严重留意,缺一不可,已经踩了2次坑了, ...

  6. delphi中的退出程序的确认问题

    在formclose中用if Application.MessageBox('你确认要退出吗?','请确认',MB_YesNo+MB_IconQuestion)=IDno then begin ... ...

  7. Linux-ln命令创建链接(软连接/硬链接)

    1.ln命令介绍 ln命令可以看作是 link 的缩写,其功能是创建文件间的链接,链接类型包括硬链接(hard link)和软链接(符号链接,symbolic link) 2.ln命令格式 ln 命令 ...

  8. LLM研究之-NVIDIA的CUDA

    一.什么是NVIDIA的CUDA CUDA(Compute Unified Device Architecture)是由NVIDIA公司开发的一个并行计算平台和应用程序编程接口(API),它允许软件开 ...

  9. 51单片机封装库HML_FwLib_STC89/STC11

    HML_FwLib_STC89/11 项目地址 https://github.com/MCU-ZHISHAN-IoT/HML_FwLib_STC89 https://github.com/MCU-ZH ...

  10. Nginx开启gzip提升访问效率

    说明 最近网站考虑开启gzip压缩试试效果,gzip是nginx服务器的ngx_http_gzip_module模块提供的在线实时数据压缩功能. 通过开启gzip功能,可对服务器响应的数据进行压缩处理 ...