functions from other files are undefined to main.c
Posted: Wed Mar 30, 2022 12:14 pm
I am trying to make LCD project based on i2s driver then I faced a problem that the functions are undefined. Then I made a simple main.c file and a another .h/.c files that contain a sum functions and still tells me the function is undefined.
main.c code:
===========================================
components.h code:
===========================================
components.c code:
===========================================
the project structure below (img1)
and the error is as below (img2)
then I moved the function(sumq) definition and prototype to main.c file and it compiled, but they didn't compile in the components.h/.c files. Looks like it's a linker problem
can you help me solve this problem?
Thanks.
main.c code:
Code: Select all
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "../components/components.h"
void app_main(void)
{
uint8_t x = 3, y = 4, z = 0;
z = sumq(x, y);
while(1);
}
components.h code:
Code: Select all
#ifndef __temp_H__
#define __temp_H__
#include <stdio.h>
uint8_t sumq(uint8_t s1, uint8_t s2);
#endif
components.c code:
Code: Select all
#include "sdkconfig.h"
#include "components.h"
uint8_t sumq(uint8_t s1, uint8_t s2)
{
return s1 + s2;
}
the project structure below (img1)
and the error is as below (img2)
then I moved the function(sumq) definition and prototype to main.c file and it compiled, but they didn't compile in the components.h/.c files. Looks like it's a linker problem
can you help me solve this problem?
Thanks.