diff mbox

include grouping

Message ID 20160713142156.GA6273@dub6
State New
Headers show

Commit Message

Neels Hofmeyr July 13, 2016, 2:21 p.m. UTC
Hi Max,

in e.g. e6052c4cc756f7d3a5023a0ba57fe8d80783967c you have added #include
<stdbool.h> in various files.

I'd like to nitpick about the place where you put it:

index 3cba5d1..3d7c244 100644
I'd prefer if we keep system headers grouped on top.
Thanks :)

~Neels

Comments

Max July 13, 2016, 2:24 p.m. UTC | #1
I recall that I've seen both variants in source code - "system before
our" and "our headers before system". I'm more inclined towards latter
but I'm open for other opinions.

On 07/13/2016 04:21 PM, Neels Hofmeyr wrote:
> Hi Max,
>
> in e.g. e6052c4cc756f7d3a5023a0ba57fe8d80783967c you have added #include
> <stdbool.h> in various files.
>
> I'd like to nitpick about the place where you put it:
>
> index 3cba5d1..3d7c244 100644
> --- a/openbsc/include/openbsc/gsm_subscriber.h
> +++ b/openbsc/include/openbsc/gsm_subscriber.h
> @@ -5,6 +5,8 @@
>  #include <osmocom/core/linuxlist.h>
>  #include <osmocom/gsm/protocol/gsm_23_003.h>
>  
> +#include <stdbool.h>
> +
>
> (there are also some more instances)
>
> I'd prefer if we keep system headers grouped on top.
> Thanks :)
>
> ~Neels
>
Harald Welte July 14, 2016, 12:36 a.m. UTC | #2
On Wed, Jul 13, 2016 at 04:24:48PM +0200, Max wrote:
> I recall that I've seen both variants in source code - "system before
> our" and "our headers before system". I'm more inclined towards latter
> but I'm open for other opinions.

the standard omsoocm coding style is:
* first the system include files
* then the osmocom libraries
* then any local includes within the project
Holger Freyther July 14, 2016, 6:37 a.m. UTC | #3
> On 14 Jul 2016, at 02:36, Harald Welte <laforge@gnumonks.org> wrote:
> 
> On Wed, Jul 13, 2016 at 04:24:48PM +0200, Max wrote:
>> I recall that I've seen both variants in source code - "system before
>> our" and "our headers before system". I'm more inclined towards latter
>> but I'm open for other opinions.
> 
> the standard omsoocm coding style is:
> * first the system include files
> * then the osmocom libraries
> * then any local includes within the project

and to add to bike shedding. If we have MODULE.h and MODULE.c., first thing MODULE.c should include is MODULE.h. This makes sure that MODULE.h has all the necessary includes to be included by itself.

I would also sort system includes last (e.g. with X11 header they would pollute your namespace and define things one should not define).

holger
diff mbox

Patch

--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -5,6 +5,8 @@ 
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 
+#include <stdbool.h>
+

(there are also some more instances)