inside ah I defined a struct and used extern Struct *struct to use an instance of this struct in other .c files and my main.c file.
Following this guide I click on the same icon but all I get is an empty window, where no variables are listed.
How do I fix this?
ah defines Queue:
typedef struct Queue
{
int size;
q_elem *root;
} Queue;
and
extern Queue **queue;
ac defines various functions queue-typical functions.
In bc I define
Queue **queue;
as variable and work on it with several functions. I work on the same **queue in my main.c file.
I use Eclipse 3.3.2 for Windows.
This is a problem with potentially two sources of error. 1 being type of declaration you are using, and 2 being the debugging environment you are using.
Addressing 2 first : In my environment, (a National Instruments compiler/debugger) when resources get tight, the debugger begins to do flaky things, like display an array of structs incorrectly as a single struct, etc. I saw this just yesterday after several hours of using my debugger. The solution is to shut down and restart the environment to reset and clear all debugger memory. All debuggers I have used are subject to this type of behavior.
Addressing 1 : First, the way you have your struct defined is not compilable. ie, the line:
q_elem *root;
Needs to be:
struct q_elem *root;
That alone may fix your problem. But you might also try to create the instance of your struct a little differently. I have not seen how you are using it, but I assume you want to create an array of structs with extern linking (perhaps for the purpose of having project scope). If this is the case, try this:
//In header file:
typedef struct QUEUE
{
int size;
struct QUEUE *root;
}QUEUE;
extern QUEUE queue[10], *pQueue;
Then:
//In .c file:
QUEUE queue[10], *pQueue;
int main(void)
{
pQueue = &queue[0];
//...
You now have a pointer to an array of QUEUE with project scope. Note that it does not allocate memory for access to the member *root
, For some pointers (no pun intended) on how to do that, Look Here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.