Go to Post ... it's us against all the bad-grammar-usin', "ya know"-slingin', graciously excepting, "congradulations"-totin', "nu kU ler"-spoutin' linguistic Luddites out there. We'll see who wins! :D - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-10-2003, 18:53
Venkatesh Venkatesh is offline
Registered User
FRC #0030
 
Join Date: Jan 2003
Rookie Year: 2002
Location: USA
Posts: 260
Venkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to behold
ifi_utilities.c

Salute to all C programmers and wizards out there,

I have a question about the EDU-RC default code. Ifi_utilities.c seems to contain "useful" functions which we can call in our code. This behavior seems similar to that of a library or header file. If I am right in thinking so, why isn't it a header file? Or if I am wrong, could somebody please inform me as to where I am wrong.

__________________
-- vs, me@acm.jhu.edu
Mentor, Team 1719, 2007
Team 30, 2002-2005
  #2   Spotlight this post!  
Unread 28-10-2003, 21:03
Jeremy_Mc's Avatar
Jeremy_Mc Jeremy_Mc is offline
GitHubber
no team
Team Role: Mentor
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Orlando, FL
Posts: 496
Jeremy_Mc will become famous soon enoughJeremy_Mc will become famous soon enough
It's really just the way most C programs are structured. Since it's a library, it's a .C file. Header files are usually used for prototyping functions, declaring GLOBAL variables and constants, and including/requiring the needed source files.

It's not mandatory that the code be in a .C file (I think...), but it's just the standard way to do things...
__________________
GitHub - Collaborate on code, documentation, etc. - http://github.com
  #3   Spotlight this post!  
Unread 28-10-2003, 22:02
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: ifi_utilities.c

Quote:
Originally posted by Venkatesh
Ifi_utilities.c seems to contain "useful" functions which we can call in our code. This behavior seems similar to that of a library or header file.
This is correct - it is a library.
Quote:
If I am right in thinking so, why isn't it a header file?
There is also a header file (ifi_utilities.h) included in the distribution. A header file is used by other source (.c) files to know what the function names are and what the arguments are. This is because the header files contain function declarations:
Code:
void Wait4TXEmpty(void);
void PrintByte(unsigned char odata);
void PrintWord(unsigned int odata);
However, the declarations only tell the C compiler what the functions are, not what they do. That is what the function definition is for:
Code:
void PrintByte(unsigned char odata)
{
  Hex_output((unsigned char) odata);
  TXREG = 13;  /* a carriage return */
  Wait4TXEmpty();
}
Function definitions belong in C files, function declarations belong in header (.h) files. It is possible to put code into header files, however there are many problems with this and it is widely considered to be a very bad thing to do.

Sorry if I oversimplified it, but maybe this will help other people understand the difference a little better too...
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 19:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi