• 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.
jimdoughertyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rmichelsCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.