0

I am trying to compile my code and the error is in my ADT module .h file at this line:

void printList(FILE* out, ListRef L);

The precise error is "list.h:42: error: expected ‘)’ before ‘*’ token"

Everything seems fine to me with the rest of the program but my compiler does not that asterisk and I have been struggling to find a solution. Am I missing a definition? Any help would be greatly appreciated.

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Banfa
0

I already included it in my .c file but do I need to include it in my .h file somehow?

0

It needs to have been included before you head is included.

The compiler reads everything in the order it appears in the files. So it reads the c file when it gets to a #include it opens and reads that if it finds another #include it then opens and reads that* taking each statement in turn. It requires everything it needs to compile a statement to have been already defined in what it has already parsed.

* Actually the pre-processor reads all the files and creates 1 large intermediary file (which you can often get the compiler to output if you desire) which is read by the actual compiler in a single pass.


So I guess in you c file you include your own header before stdio.h, you can either

  1. Alter the order of the headers in you c file
  2. Include stdio.h into your header**

** header files are normally written to protect against double inclusion to allow this (i.e. many headers and C file might include the same header). Also some coding standards prohibit inclusion of headers into other headers but that is a matter of style.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.