首页 > 解决方案 > '*' 标记之前的预期初始化程序

问题描述

我正在尝试创建一个控制台应用程序,该应用程序在我正在使用的网络书籍的帮助下利用套接字和 ncurses。在编译时,我收到错误 'expected initializer before '*' token for the line:

WINDOW* create_newwin(int height, int width, int starty, int startx);

在包含一些我忘记包含的新标头(主要是网络标头)之前,我没有收到此错误。

//我在错误之前的标题

#include <ncurses.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>

//当错误开始抛出时我添加的标题

#include <stdio.h>      //for printf() and fprintf()
#include <sys/socket.h> //for socket(), connect(), send(), and recv()
#include <arpa/inet.h>  //for sockaddr_in and inet_addr()
#include <unistd.h>     //for close()
#include <iostream>
#include "DakchatHeader.hpp"

我知道这是标题,因为当我将它们注释掉时,特定的错误就会消失(但会出现关于未知功能等的错误)。

还应该注意的是,当我调用它时,它表示未知函数,并且 WINDOW 是在 ncurses 中定义的。

感谢您能给我的所有帮助!

标签: c++compiler-errors

解决方案


在我包含的 DakchatHeader.hpp 文件中,我在创建结构后忘记添加分号。修复后不再显示错误。


推荐阅读