CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How do i make header files

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
BOB_SANTANA



Joined: 16 Oct 2006
Posts: 110
Location: HOVE, EAST SUSSEX

View user's profile Send private message

How do i make header files
PostPosted: Sat Dec 02, 2006 4:39 pm     Reply with quote

Hi All

Could someone be kind enough to explain how i can make my own
headed files like ( #include <myfunctions.h> )
for all my functions
So i can include it to my projects

Regards
_________________
BOB_Santana Smile
ferrumvir



Joined: 01 Feb 2006
Posts: 64
Location: England

View user's profile Send private message Visit poster's website

PostPosted: Sat Dec 02, 2006 5:22 pm     Reply with quote

Open a new file in a text editor and save it with '.h' extension. Write your routines in the file just as you would normally. Then use the #include statment to include the file in your source.

The #inlcude statment is a compiler directive and tell the compiler to replace the #inlucde statement with the contents from the file. The comiler compiles as if those routines were in written directly in the file.

There is a another thing you can do with header files, but I've not seen it used with PICs. It's used heavily in larger (PC based) projects.

The header file includes function declarations, this requires a second source file comtaining all the functions '.c' Both the main c file and this c file include the header, and are compiled separately, creating to object files '.o.. The linker (one of the later stages of the compilation process links routines from the two object files together.

In large projects this can be used to encapsulate sections of the code. The inferface between code sections is the header file. The sections can then be modified knowing that it will not affect another part of the application, and becomes very reusable.

I've not yet managed to do this for my PIC programming because each program tends to use taylored algorithims.

Cheers Scott
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group