When the same function is defined in a different source file, and included with #include statement, it still compiles correctly but generates the a linker error.
Here is the code that build, links and runs correctly all from the same source file:
Function Definition:
Code: Select all
void print_hex_character_local (unsigned char character)
{
if (character < 16) printstr("0");
printhex(character);
}
void print_packet_local (unsigned char packet[], unsigned int packet_length)
{
printstr("Length = ");
printuintln(packet_length);
unsigned int array_index = 0;
while (array_index < packet_length)
{
if ((array_index % 16) == 0)
{
printstr("\n");
print_hex_character_local(array_index >> 8);
print_hex_character_local(array_index);
printstr(" ");
}
print_hex_character_local(packet[array_index]);
printstr(" ");
array_index++;
}
printstr("\n\n");
}
Code: Select all
print_packet_local(buf, 48);
Code: Select all
void print_hex_character (unsigned char character)
{
if (character < 16) printstr("0");
printhex(character);
}
void print_packet (unsigned char packet[], unsigned int packet_length)
{
printstr("Length = ");
printuintln(packet_length);
unsigned int array_index = 0;
while (array_index < packet_length)
{
if ((array_index % 16) == 0)
{
printstr("\n");
print_hex_character(array_index >> 8);
print_hex_character(array_index);
printstr(" ");
}
print_hex_character(packet[array_index]);
printstr(" ");
array_index++;
}
printstr("\n\n");
}
Code: Select all
void print_packet (unsigned char packet[], unsigned int packet_length);
Code: Select all
#include "custom_print.h"
Code: Select all
print_packet(buf, 48);
Any idea why this is happening?Creating App_500_Rack.xe
D:/CSSD Documents/XMOS/Workspace/500Rack3PortTest/module_gptp/src/gptp.xc: Error: Undefined reference to '_Sprint_packet_0'
xmake[1]: *** [bin//App_500_Rack.xe] Error 1
xmake: *** [bin//App_500_Rack.xe] Error 2