LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-27-2005, 03:01 AM   #1
Mistro116@yahoo.com
Member
 
Registered: Sep 2005
Posts: 118

Rep: Reputation: 15
#include hierarchy


Hello,

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?

Thanks in advance,

Mistro116
 
Old 11-27-2005, 10:34 AM   #2
vivekr
Member
 
Registered: Nov 2005
Location: Coimbatore,India
Distribution: Fedora Core4
Posts: 68

Rep: Reputation: 15
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.
 
Old 11-27-2005, 12:50 PM   #3
Mistro116@yahoo.com
Member
 
Registered: Sep 2005
Posts: 118

Original Poster
Rep: Reputation: 15
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?

Mistro116
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Level Hierarchy Mistro116@yahoo.com Programming 4 11-27-2005 05:30 PM
where to store mp3 in file hierarchy leopardb Linux - Newbie 6 07-05-2005 10:40 AM
Creating a group hierarchy? statuszero Linux - Security 5 07-16-2004 04:18 PM
Desktop hierarchy filesystem: I WANT TO CHANGE IT!! opioid Linux - Software 2 03-28-2004 02:32 AM
Filesystem Hierarchy Question - You probably get these alot. Sorry :( JoeLinux Linux - Newbie 4 04-23-2002 10:33 AM


All times are GMT -5. The time now is 08:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration