On 22.12.2013 16:51, Ravi Shekhar Jethani wrote: > > Now, my real question : > 1) I cannot understand the reason behind making function prototypes as > extern. What purpose does this serve? AFAIK we put definition in a .c > file and the prototype in a .h thats it. > > 2) Why are some prototypes in some of the .h file are extern and > others are not? > > Thank you guys for reading through. Any suggestions are humbly welcome. > Ravi S. Jethani > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > That's an interesting question. From my understanding there is no difference for functions declarations being set to extern or not, because extern is the default on functions. It is however important for variables to mark them extern if they're in a header file. After a quick research on the web, it may be there for historical reasons. Back then, when there were one pass compilers, the compiler needed to know where the function is to be found. (extern was not default at these times?) Another reason I could make up, would be to indicate, whether the function is in the c file having the same name as the header file. For example in builtin.h there are all the functions declared extern, as the implementation of the functions are found in builtin/*.c In another header cache-tree.h there are function declarations without explicit extern keyword, and the implementation is found in the cache-tree.c file (${SAME-NAME-AS-HEADER}.C) This is however not always the case as found in archive.{c,h} I'd be also interested in knowing the real reason for this rationale. Thanks, Stefan -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html