Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to include files

Status
Not open for further replies.

ghostman11

Well-Known Member
hi guys.
been in bed with flu for couple weeks :( but its given me plenty time to play with pics!! so finaly feels like ive had a chance to try and nail a few basics and try a few things out!!! i am finaly starting to be able to get information out the DS!!! YAY (yes its taken way too long).
anyway been trying to get to grips with c18 wich as you all know has remained a complete mystry to me!!
making slow progress but realy enjoying it and as i am stuck in bed i get plenty chance to concentrate at last. anyway down to business.........
ive been trying a few things out and trying to avoid the 'soft' option of using c18 libs that are suplied as i figured i would learn more from making my own functions by study of DS.
some of theese functions i would like to group into collections say AD functions and put into a seperate file, then be able to call in the file into any prog i like by using the

#include<blah blah>.c (kind of thing)
but at the moment i dont realy want to go as far as nailing howto do proper libs like the ones microchip supply.
all i would like if its poss is to use an include statment in main program like above so i can then just add in any variables needed ect for the and use the functions. yes would be easier to simply cut and paste the functions in each time but i would like to keep main.c clutter free! and have the functions in a sep file.
can this be done and if so how do i do it!! i have trawled the net but it seems to just relate to proper libs.
BTW i am not bothere about diff chips being compatable at the mo , once ive got better at actualy codeing then i will move onto the making of proper libs that can transfer to other chips
sorry if its a bit of a ramble but on heavy duty painkillers for my back at the mo! :D
 
Hey Ghostman,

The way I do it is simply put at the top of your file:

#include <test.c>


Then you have to go into your project options and add the location of that file to your 'include search path'.

Project > Build Options > Project > (tab) Directories > (drop-down menu) Include Search Path > Add New (then point it to the directory which has the file you want to include).

^ The menu location is off the top of my head and my memory is sketchy, at best.
 
Last edited:
ok thanks!!! i was completly forgetting the adding the include in mplab!!! DOH! always the silly stuff that bites you hardest lol
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top