![]() |
Calling functions from other documents
In MPLAB, how do I call functions from other files in a project?
Here is my code: Code:
static int counter;Here is the function code: Code:
long Get_Encoder_3_Count(void)Error - could not find definition of symbol 'Get_Encoder_3_Count' in file 'V:\frc-code-2007-8722\FrcCode_2007_8722\user_routines.o'. |
Re: Calling functions from other documents
declare the function reference as external to your source file.
Code:
extern long Get_Encoder_3_Count(void); |
Re: Calling functions from other documents
are you #include'ing?
|
Re: Calling functions from other documents
I have the both the files encoder.c and encoder.h included. I added the external identifier, but I still get the same error.
Here is my new code: Code:
static int counter; |
Re: Calling functions from other documents
If you're using more than one function from a file, you could just include that file's header file. Use quotes if it's not a library that comes with the compiler.
#include "myfile.h" |
Re: Calling functions from other documents
I Have the code:
#include "encoder.h" #include "encoder.c" located at the top of the document |
Re: Calling functions from other documents
It sounds like you haven't set up the encoder stuff correctly. Not all the encoder code is enabled by default. If that's the case then that routine isn't being compiled - its being excluded because ENABLE_ENCODER_3 isn't defined.
There is an encoder_readme.txt file in the documentation directory and there is info in the encoder.h file. Is the ENABLE_ENCODER_3 line in .h un-commented? |
Re: Calling functions from other documents
You don't need to include "encoder.c", and in fact, you probably shouldn't.
I don't think that's the problem, but if you include a .c file, you're probably going to get an error about something like multiple declarations of something. The headers tells the file that a function exists somewhere in one of the .c files. The actual code for that function doesn't need to be in the same .c file the function is used in. |
Re: Calling functions from other documents
Take a few steps back. Undo everything you've tried to do in order to make it work. Read the documentation (I think it's called encoder_readme.txt) that comes with the encoder software. Follow the steps (nine of them, if I recall correctly) to add the code to your project and configure it.
If it still doesn't work, let us know. |
Re: Calling functions from other documents
Quote:
|
| All times are GMT -5. The time now is 23:54. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi