|
|
View previous topic :: View next topic |
Author |
Message |
glennjammin
Joined: 22 Aug 2013 Posts: 2 Location: Utah
|
Function used but not defined Error |
Posted: Thu Aug 22, 2013 10:00 am |
|
|
I keep getting this error with the CCS compiler.
Quote: |
--------------------Configuration: LedSignalDisplay - Debug--------------------
CCSC +STDOUT -P I+="X:\Consulting\MarshallRadio\src\lib" +OBHEX +P +FH -A +Y9 +M +EA +ICD +D X:\Consulting\MarshallRadio\src\app\LedSignalDisplay\LEDSignalDisplay.c
*** Error 112 "LEDSignalDisplay.c" Line 5(1,1): Function used but not defined: ... TLC5929_New 688 SCR=1132
1 Errors, 0 Warnings.
Build Failed.
LEDSignalDisplay.HEX - 1 error(s), 0 warning(s)
|
Any ideas as to why the compiler cant find the function?
Thanks for you help in advance.
Here is the main function:
Code: |
#define DEVICE_18F85J11
#include "config.h"
#include <TLC5929/tlc5929.h>
void main()
{
TLC5929 *redBar0 = TLC5929_New();
// redBar0->TLC5929Init(redBar0,RED_BAR_0_DO,RED_BAR_0_DI,RED_BAR_0_CLK, RED_BAR_0_LAT);
TLC5929_Delete(&redBar0);
}
|
Part of tlc5929.h:
Code: |
typedef struct
{
SPIBB *m_pSpiInterface;
FunctionControl m_functionControl;
LEDControl m_ledControl;
int (* TLC5929Init)(void *pTLC5929,unsigned long sout, unsigned long sin, unsigned long sclk, unsigned long lat);
int (* SetBrightness)(void *pTLC5929,unsigned int val);
int (* SetLEDEnable)(void *pTLC5929,unsigned int val);
int (* Write)(void *pTLC5929);
unsigned long (* Read)(void *pTLC5929);
}TLC5929;
/**
* SPIBB_New
* @brief Constructor to the psudo class SPIBB
*
* return new SPIBB object
**/
TLC5929* TLC5929_New();
/**
* SPIBB_Delete
* @brief Destructor to the psudo class SPIBB
*
* @param[IN] this Pointer to the SPIBB psudo class
**/
void TLC5929_Delete(TLC5929 *this);
|
TLC5929_New() from tlc5929.c:
Code: |
TLC5929* TLC5929_New()
{
TLC5929* newInstance = malloc(sizeof(TLC5929));
if(newInstance == 0)
return 0;
newInstance->m_pSpiInterface = SPIBB_New();
if(newInstance->m_pSpiInterface == 0)
return 0;
newInstance->TLC5929Init = &TLC5929Init;
newInstance->SetBrightness = &SetBrightness;
newInstance->SetLEDEnable = &SetLEDEnable;
newInstance->Write = &TlcWrite;
newInstance->Read = &TlcRead;
return newInstance;
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Aug 22, 2013 10:48 am |
|
|
You don't show tlc5929.c being included anywhere.
Best Wishes |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Fri Aug 23, 2013 1:35 am |
|
|
Ttelmah wrote: | You don't show tlc5929.c being included anywhere.
|
Nor is there any visible include of stdlibm.h, which is required for dynamic memory support. In any case, the very tight RAM limits make dynamic memory inadvisable, or in the hands of inexperienced programmers, suicidal project-wise. Many C style guides ban, or at least strongly deprecate any use of dynamic memory in C embedded applications, both for the lack of RAM, and for the potential pointer related issues.
Function pointers are another problem, as CCS C must be able to resolve function pointers at compile time. Due to limitations of the processor architecture it cannot resolve function pointers at run time. Essentially, on PICs as code and data are two totally separate memory systems with different and sometimes incompatible address spaces, it is very difficult indeed to relate the two at run time, and it requires special tricks to do it at compile time. In short, practically all attempts to do object style code are likely to fail at some point as the processor simply isn't built to allow it.
This looks like an attempt to translate some C++ into C. That really is not a good way to implement C code. Its far better to write C from the ground up, which implies a good working knowledge of the device, in this case a fairly straightforward LED lamp driver that would be simpler, easier to debug and far more understandable in straight, non dynamically allocated C. It's your choice though, but already the C++ into C approach has caused you enough trouble to seek help on this forum. |
|
|
glennjammin
Joined: 22 Aug 2013 Posts: 2 Location: Utah
|
|
Posted: Sat Aug 24, 2013 1:19 pm |
|
|
Thanks for the response.
I thinking about it a bit I decided to eliminate the dynamic memory way of doing it and things are working a lot better.
Also you only have to include the .c file in the main file when you are compiling to one compile unit. If you are creating multiple compile units you just need to include the .h files. Although you need to be sure the configuration settings such as #include <device header file.h> is included in each file. Or create a configuration file and include it in each file.
http://www.ccsinfo.com/faq.php?page=multi_comp_units
Thanks for all the help, I greatly appreciate it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sat Aug 24, 2013 2:05 pm |
|
|
Somewhere in the main compilation, you have to include the definitions telling the compiler 'where' to find the function.
Yours doesn't.
Hence won't be found.
Study the example. See how the main project file says 'what' to import. You are not showing anything similar. |
|
|
|
|
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
|