git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Rationale behind 'extern' on protypes in .h files

From
RJRavi Shekhar Jethani <rsjethani@gmail.com>
Date
Dec 22, 2013, 15:51 UTC
Message-ID
<CAKTJ_1zecXP03k_2YRnm_26n=anxkG6=k+isZxnnjWgfec70LA@mail.gmail.com>

Hi, I am a C & Data Structure teacher at at an institute. Up until now I have only written classroom type C code. I always had interest in operating systems especially Linux Kernel but never got into anything just passively followed 'lwn.net', 'dr dobbs magazine' etc.

But the series '30 Linux Kernel Developers in 30 Weeks' on 'linux.com' has really pushed me over the edge and I have this new found interest towards Linux and C. As these articles suggest that I should have a good experience in user space before I can even touch the kernel. So to get a feel of how actual real world C projects look like I have taken two excellent projects as my reference 'Git' and 'libvirt'. Also 'Linux Formrnal Scratch' to get started towards Linux internals.

Although I have a good understanding of the basic/advanced concepts like pointers, memory management etc but many concepts like good error handling mechanism, unit testing, build systems etc. were always blurry but I know that this is just a start towards a long journey towards Linux Kernel.

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

Next: Stefan Beller
Message 1 of 5 in “Rationale behind 'extern' on protypes in .h files”
  1. Ravi Shekhar JethaniDec 22, 2013
  2. Stefan BellerDec 22, 2013
  3. Jed BrownDec 22, 2013
  4. Ravi Shekhar JethaniDec 23, 2013
  5. Jed BrownDec 23, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.