C

Asked • 06/12/19

What is a "static" function?

The question was about plain [tag:C] functions, not [tag:C++] `static` methods, as clarified in comments.Ok, I understand what a `static` variable is, but what is a `static` function?And why is it that if I declare a function, let's say `void print_matrix`, in let's say `a.c` (WITHOUT `a.h`) and include `"a.c"` - I get `"print_matrix@@....) already defined in a.obj"`, BUT if I declare it as `static void print_matrix` then it compiles?**UPDATE** Just to clear things up - I know that including `.c` is bad, as many of you pointed out. I just do it to temporarily clear space in `main.c` until I have a better idea of how to group all those functions into proper `.h` and `.c` files. Just a temporary, quick solution.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.