View previous topic :: View next topic |
Author |
Message |
PeWa
Joined: 15 Jan 2019 Posts: 22 Location: Sweden
|
Function Used but not defined |
Posted: Tue Jun 15, 2021 3:19 am |
|
|
Hello a quick question before I post more code.
Compiler 5.076 PIC30F4011
I am up to convert a C file for a Analog DDS chip from Linux C to CCS C.
Almost done but
I got "not defined error" when I try to use a function from the external c file, I do have the same header file included in main and the header also contains function declarations for all functions.
In CCS explorer the C file I have included into the project is blue in color.
If I hover over it and check information it says "Not used in last build".
Is that why it is blue ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Jun 15, 2021 7:16 am |
|
|
OK.
What you are trying to use is almost certainly from a traditional 'linking'
compiler. The standard way that C works on such a compiler is that you
include the 'header' file, and then at compile time, 'link' the already compiled
code for this. Now you can use CCS like this. However you are then going
to have to build each of the parts separately, and have a file to #import
each of the .o files for the compiled sections. Until they are imported the
compiler will keep complaining that the function definition does not exist.
By default, CCS is normally used with only one compilation unit. Instead
of building with MCU's like this, you instead actually #include the real .c file
for the other units and let the compiler compile all of them. The big advantage
of this is that it allows the compiler to better optimise memory usage. |
|
|
PeWa
Joined: 15 Jan 2019 Posts: 22 Location: Sweden
|
Function Used but not defined |
Posted: Tue Jun 15, 2021 12:32 pm |
|
|
Ttelmah, thanks for input.
I have fixed it, some time it is worth taking a pause and come back to the code.
The problem was that I had only the header file included in main
but the .c file and header file was included in the project.
When I included the .c file to main i had to get rid of the header and use that only in the .c file for that header.
The blue color means not compiled with project then. |
|
|
|