Alongside main.c
file, I have following my_custom_data_structure.c
file in my project. My my_custom_data_structure.c
file contains a lot of variables, functions, etc.
I am using #include "my_custom_data_structure.c"
directive in main.c
.
Problem
I would like to import only single function called foo
from my_custom_data_structure.c
. I don't need all the variables and functions, which are declared in my_custom_data_structure.c
file.
Any insights appreciated.
File structure
-
|- main.c
|- my_custom_data_structure.c
Content of my_custom_data_structure.c
#include <stdio.h>
int DELAY = 20;
int SPEED = 7;
char GRANULARITY_CHAR = 'g';
unsigned int RANGE = 3;
void foo(){
// TODO: In future, this function will print SPEED.
printf("foo works!");
}
/*
The rest of this file is filled by a lot
of code, which is not needed for main.c
*/
Content of main.c
#include <stdio.h>
#include "my_custom_data_structure.c"
int DELAY = 3;
int main(){
foo();
printf("Delay is %d", DELAY);
return 0;
}
UPDATED: Added working example