ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am writing several programs with different class and header files. I have come across the problem that some of the function prototypes in my header files contain data types that are specific to certain libraries, such as FILE in <stdio.h>. I was told there is a way to have the header file compile with the class file if your order the #includes correctly in your class file and main file.
So far, the only way I see to get around this is to #include <stdio.h> and whatever other libraries in my header file to get the data type to be recognized; however, I've been told this is not necessary and is, in essence, "not the best way to do it".
I was told to #include my library files in order and then my #include my own header file in the class file, which is what I usually do, but this doesn't take care of my problem. What can I do to get rid of the "parse error" that the compiler gives me from failing to recognize the data type?
What I feel is that the latter solution of inclusion of all the includes wouldn't make any difference. The final image of the program will be the same for both. If you can provide the exact errors there is a scope to identify the errrors.
This is the error I get when I do not #include <stdio.h> in my header file:
Code:
/* Word constants */
#define WORDARRAYSIZE 16 /* The size of the
character array
variable in the
WORD structure. */
/* Letter constants */
#define LETTERARRAYROWSIZE 17 /* The size of the
rows for the
two-dimensional
array of characters
that will contain
the list of letters
to be searched
through in a 15 x
15 grid form, with
a one row and one
column buffer
around the grid of
characters. */
#define LETTERARRAYCOLUMNSIZE 17 /* The size of the
columns for the
two-dimensional
array of characters
that will contain
the list of letters
to be searched
through in a 15 x
15 grid form, with
a one row and one
column buffer
around the grid of
characters. */
/* This structure will be used to represent one word that
was read in from the input file containing a list of
words to search for in the list of letters in 15 x 15
grid form. An array of words will be dynamically
allocated to be manipulated and represented as a series
of words to be searched for in the list of letters in 15
x 15 grid form. */
typedef struct word
{
char word [WORDARRAYSIZE];
int startRow;
int startCol;
char direction;
}WORD;
void PrintGreeting (void);
void GenerateLetterList (char inputFileName [ ]);
void ReadLetterList (FILE *inputFile, char letters
[LETTERARRAYROWSIZE][LETTERARRAYCOLUMNSIZE]);
void DisplayLetterList (char letters
[LETTERARRAYROWSIZE][LETTERARRAYCOLUMNSIZE]);
void GenerateWordList (char inputFileName [ ]);
void InitializeWordArray (WORD *wordArray, int numberOfWords);
int CountNumberOfWords (FILE *inputFile);
void ReadWordList (FILE *inputFile, WORD *wordArray, int numberOfWords);
void DisplayWordList (WORD *wordArray, int numberOfWords);
void GenerateSearchResults (char outputFileName [ ], WORD *wordArray, int numberOfWords);
void PrintSearchResults (FILE *outputFile, WORD *wordArray, int numberOfWords);
When <stdio.h> is included, the code compiles fine. What do you think is the problem? Is there a way I can get rid of these errors without #include <stdio.h> in my header file?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.