gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
how can i declare a list that is type struct expr like expr* list = NULL in my .h file…
- User
how can i declare a list that is type struct expr like expr* list = NULL in my .h file without getting error of previous declaration?
- Assistant
You can declare it using an include guard in your .h file. Here's an example:
code#ifndef MY_HEADER_FILE_H #define MY_HEADER_FILE_H struct expr { // define your struct members here }; typedef struct expr Expr; Expr* list = NULL; #endifThe include guard (
#ifndef MY_HEADER_FILE_H) ensures that the contents of the file are only included once, even if the file is included multiple times.