I have the well-known errors :
implicit declaration of function 'STLINKReadSytemCalls' [-Wimplicit-function-declaration]
implicit declaration of function 'printf' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in function 'printf'
And Eclipse (Atollic TrueStudio more precisely) kindly added :
include '<stdio.h>' or provide a declaration of 'printf'
Reading the billions of post asking how to solve this problem on SO, it seems that three problems might cause these errors :
- Functions are defined after main;
- Required headers to use a function are included
#ifndef
,#define
and#endif
do not correctly wrap the header files
I have found a post in which someone seemed to have this error and said after fixing it that Eclipse was the problem. Can't find the topic though, but his solution didn't work for me. It was something like clicking on the function, source -> add includes.
main.c
int main(void) {
if (STLINKReadSytemCalls() == 1)
printf("Error in system calls.\n");
return 0;
}
fileProcessing.c
#include "../header/fileProcessing.h"
int STLINKReadSytemCalls(void) {
// mainly system calls
}
fileProcessing.h
#ifndef FILEPROCESSING_H_
#define FILEPROCESSING_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int STLINKReadSytemCalls(void);
#endif /* FILEPROCESSING_H_ */
The most confusing part is that the code actually works. I have the following output :
STM32 ST-LINK CLI v3.0.0.0
STM32 ST-LINK Command Line Interface
No ST-LINK detected
Unable to connect to ST-LINK!
Error in system calls.
Everything seems to be fine, but compiler keeps yelling. I'll add the function's body if needed, but I have seen nowhere any clue telling that a function's body could cause an include error. I must be missing something so obvious that I'll self-facepalm like no one ever did when I'll see it; but I have already spent hours and my hope that this is obvious is getting thinner.
Oh, and yesterday with the same include path and same directory build it worked perfectly fine. I really don't know what changed since.