When we want to use a function say void foo(void) in File1.c in my Main.c [ where my main function is ] – why do i not need to write:
extern int main(void);
In File1.c?
Assuming
File1.candMain.care in a Single TU.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You never need to write
externwith function declarations. Functions have external linkage by default. There’s a strange unexplainable habit observed in some older code: to addexternto all external function declarations. (This is probably what led to your question aboutmain.) In reality, it is completely unnecessary, serves no purpose and only clutters the code.You can surely declare
mainwithextern, if you so desire. But it is totally redundant.