Given that all (non-static) function declarations are extern
by default, is there any point in preceding a function declaration with extern
or is it just poor coding practice?
Asked
Active
Viewed 56 times
0

Lolo
- 3,935
- 5
- 40
- 50
-
1It's pointless, at least with all environments I'm aware of. [This SO article](https://stackoverflow.com/a/856736/898348) may help – Jabberwocky Mar 03 '21 at 09:53
-
6In the professional environment I am working in currently, we are required to declare as `extern` the functions which will be required by other systems. All our functions are exposed for testing purposes, but the ones declared as `extern` are explicitely for external use. There is no technical change, but it makes a 3000-files codebase more readable, knowing which are the internal and which are the exposed functions – Adalcar Mar 03 '21 at 10:08
-
Sometimes it's good to express your intention not only to a computer, but to the person that will be reading the code later as well. Just my two cents. – gstukelj Mar 03 '21 at 11:48
-
@Adalcar Thanks, using extern as a way of better commenting the code. This makes good sense. – Lolo Mar 03 '21 at 14:53