0

For speller.c, you can't pass a pointer to the root node (I'm using a trie) to check(), size(), and unload(). And I couldn't create a global root node in dictionary.c

error: initializer element is not a compile-time constant

So, how do they know what to check, measure and unload?

  • How do you initialize the pointer when declaring it as a global variable? – Kareem Jun 16 '14 at 13:36
  • There's this function, called getNode() I created, which returns a pointer to an empty node. So, in dictionary.c, I initialized struct node* root = getNode(); outside the functions, so it will be accessible to all functions. – ballaneypranav Jun 16 '14 at 15:00
  • You may try initializing it to NULL initially like struct node* = NULL; – Kareem Jun 16 '14 at 15:01
  • struct node* is a data type! How can I initialize a data type to NULL? – ballaneypranav Jun 16 '14 at 15:12
  • I'm sorry I meant struct node* root = NULL! – Kareem Jun 16 '14 at 18:02
2

So that error was being caused because the function getNode() was being used outside another function. Turns out, clang doesn't like that.

So I did the following:

node root_node;
node* root = &root_node;

That fixed it!

  • Did you add those lines to dictionary.c, outside of the load function? – Jesse Sep 21 '14 at 11:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .