So my situation is something like this, I have three files:
main.c:
#include <stdio.h>
#include "hello.h"
int main() {
hello();
}
hello.h:
void hello();
hello.c:
void hello() {
printf("Hello");
}
My Cmake file looks something like this:
cmake_minimum_required(VERSION 3.3)
project(test)
set(SOURCE_FILES main.c hello.c)
add_executable(test ${SOURCE_FILES})
The code runs fine. However CLion doesn't recognise the printf()
function in hello.c, and wants me to add it as a header file. Is there a way to make it see the #include <stdio.h>
in the main.c file, and stop giving me a hard time?
So I fixed this to my own satisfaction by making the functions defined in my .c files return values rather than calling printf inside those functions. Then printing the values returned in main.c