Cross Linking Functions.

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Cross Linking Functions.

Postby SLTom992 » Thu Jul 17, 2014 8:33 pm

I have two C programs in the same project:

The Main which contains all the interrupt procedures and the processes driven by them and the Display which contains all of the graphics display routines and the font.

For the life of me I cannot remember how to make it so that I can call functions across files in the same project. I tried looking it up in two C manuals and couldn't find anything pertinent. I'm using XC-8.

Can someone remind me?
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Cross Linking Functions.

Postby vloki » Thu Jul 17, 2014 9:44 pm

vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Cross Linking Functions.

Postby ric » Thu Jul 17, 2014 9:47 pm

That web page wrote:Note:
A newer, revised version of this article has since been posted
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Cross Linking Functions.

Postby vloki » Thu Jul 17, 2014 10:10 pm

ric wrote:
That web page wrote:Note:
A newer, revised version of this article has since been posted

:lol: http://www.microchip.com/forums/FindPost/779164
IanM wrote:@Vloki: I continue to recommend the original because I have taken the time to read it thoroughly and am confident that the C++ content isn't too intrusive...
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Cross Linking Functions.

Postby Ian.M » Thu Jul 17, 2014 11:06 pm

Yep. I've compared them side by side in a two column view and the new version has about 10% extra C++ only stuff and the rest of the text is 10% more verbose but no clearer. The author must have been paid by the word to rehash it!.
Ian.M
Verified identity
 
Posts: 95
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Cross Linking Functions.

Postby SLTom992 » Fri Jul 18, 2014 3:30 am

Thanks for the help.
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Cross Linking Functions.

Postby SLTom992 » Fri Jul 18, 2014 7:06 pm

OK, obviously I'm missing something obvious - if I use the term "class" as it appears to be used in this explanation I get the error message "unexpected token". If in this document "class" is meant to mean some general term of a more specific term it doesn't appear to be explained in the document plainly.

I should add that although I've been programming in many languages for many years that I suffered a severe concussion that effects the memory strangely (suppose you could still add two plus two but couldn't remember what a "+" sign looked like?)
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Cross Linking Functions.

Postby jtemples » Fri Jul 18, 2014 7:37 pm

"class" is a C++ keyword. You can't use it in C.
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Cross Linking Functions.

Postby SLTom992 » Fri Jul 18, 2014 8:55 pm

Then what do you do to link two C files (and .h files) so that they will compile. The error messages I'm getting shows that each C file can't recognize function names or #defines from the other C file.
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Cross Linking Functions.

Postby jtemples » Fri Jul 18, 2014 9:03 pm

#defines are not visible between C files. If you want multiple C files to be able to see them, they have to be in a header file included by those C files. You'll also want to put a declaration of the function prototype in a header file that's included by any C files that want to use the function, as well as by the C file that defines the function.
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Next

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 7 guests

cron