Here is the code: globalfuncvars.h:
#ifndef GLOBALVARIABLES_H
#define GLOBALVARIABLES_H
#include <bits/stdc++.h>
#include "ast.h"
#include "commandline.h"
using namespace std;
extern int cnt;
extern int key_count, sep_count, opt_count, id_count, lit_count;
extern ast *parse_tree_root;
extern ast *ast_root;
#endif
ast.h:
#ifndef AST_H
#define AST_H
#include <bits//stdc++.h>
#include "globalfuncvars.h"
using namespace std;
class ast{
public:
/* class definition */
};
#endif
The file ast.h uses the cnt
variable from globalfuncvars.h. I want to include the globalfuncvars.h file in my main.cpp but upon compiling, I get the error:
./src/globalfuncvars.h:19:8: error: ‘ast’ does not name a type
19 | extern ast *parse_tree_root;
| ^~~
./src/globalfuncvars.h:21:8: error: ‘ast’ does not name a type
21 | extern ast *ast_root;
How do I fix this?