• C

Linking several c files

This question pertains to a c project that contains more than one c file to be linked. I understand that the global variables declared in one c file will not be known to the other c files unless I use extern in each of the other files, declare the variable in a .h file, and include the header files in each of the c files. How can I do the same with functions. If I prototype a function within the same c file (not .h file), will the function be kept private from the other c files. If not, how can I do this.
Who is Participating?
rmichelsConnect With a Mentor Commented:
When creating your function, use the keyword Static to keep the function local to the module.

Any function without the static will be global, though other modules will not know the true prototype (params and return type).

static void func(); would be the prototype

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.