“warning: 'struct matrix' declared inside parameter list [enabled by default]” and error: conflicting types for 'scanToken'

只谈情不闲聊 提交于 2019-12-02 02:20:04

You have to declare struct matrix outside a function prototype, like the error message implies.

You have in your scanner.h header:

struct token scanToken(struct matrix refTable);

Since there's no prior declaration of struct matrix in that header, or a header read before it is read, the struct matrix is a new distinct type. It's also incomplete, so you really need to use a pointer to it.

You can fix it as simply as:

struct matrix;
struct token scanToken(struct matrix *refTable);

To be able to pass the struct matrix by value instead of by pointer, you need a full definition of the structure, but pointers can be passed to incomplete types.

Or include the header that defines the struct matrix fully in the scanner.h header.

Note that you should protect your headers with multiple inclusion guards:

#ifndef SCANNER_H_INCLUDED
#define SCANNER_H_INCLUDED

…current contents…

#endif // SCANNER_H_INCLUDED

You might well add #include "otherheader.h" in that one — the other header that defines struct matrix in full.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!