Skip to content

Commit 89a831d

Browse files
authored
CQ: always include stdbool.h if bool is used in C code (#5618)
Always `#include <stdbool.h>` where `bool` is used i C code. For the same reason, revert (part of 1e0c11f) definition of `TRUE` and `FALSE` (in gis.h) to `1` and `0`, in order to avoid the inclusion everywhere it may/should have been needed. In addition, starting with C23 `bool` is not an int, but a type of its own, making it not interchangeable with int.
1 parent 1ec7ebd commit 89a831d

File tree

23 files changed

+28
-10
lines changed

23 files changed

+28
-10
lines changed

general/g.region/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
****************************************************************************/
1515

1616
#include <string.h>
17+
#include <stdbool.h>
1718
#include <stdlib.h>
1819
#include <math.h>
1920
#include <grass/gis.h>

include/grass/defs/raster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef GRASS_RASTERDEFS_H
22
#define GRASS_RASTERDEFS_H
33

4+
#include <stdbool.h>
5+
46
#include <grass/gis.h>
57

68
/* --- ANSI prototypes for the lib/raster functions --- */

include/grass/defs/vector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef GRASS_VECTORDEFS_H
22
#define GRASS_VECTORDEFS_H
33

4+
#include <stdbool.h>
5+
46
/*
57
* "Public" functions, for use in modules
68
*/

include/grass/gis.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/* System include files */
2323
#include <stdio.h>
2424
#include <stdarg.h>
25-
#include <stdbool.h>
2625

2726
/* Grass and local include files */
2827
#include <grass/config.h>
@@ -76,11 +75,11 @@ static const char *GRASS_copyright UNUSED = "GRASS GNU GPL licensed Software";
7675
*/
7776
/* and 'false' For historical reasons 'TRUE' and 'FALSE' are still valid. */
7877
#ifndef TRUE
79-
#define TRUE true
78+
#define TRUE 1
8079
#endif
8180

8281
#ifndef FALSE
83-
#define FALSE false
82+
#define FALSE 0
8483
#endif
8584

8685
/*! \brief Cross-platform Newline Character */

lib/gis/mapset_msc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <grass/config.h>
1313
#include <string.h>
1414
#include <unistd.h>
15+
#include <stdbool.h>
1516
#include <stdlib.h>
1617
#include <errno.h>
1718
#include <sys/types.h>

lib/gis/parser_md_python.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
\author Vaclav Petras
1212
*/
13+
#include <stdbool.h>
1314
#include <stdio.h>
1415
#include <string.h>
1516

lib/raster/mask_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <string.h>
17+
#include <stdbool.h>
1718
#include <stdlib.h>
1819

1920
#include <grass/gis.h>

lib/raster/raster_metadata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
\author Hamish Bowman
1414
*/
1515

16+
#include <stdbool.h>
1617
#include <stdio.h>
1718
#include <string.h>
1819

lib/rst/interp_float/init2d.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*
2020
*/
2121

22+
#include <stdbool.h>
2223
#include <stdio.h>
2324
#include <math.h>
2425
#include <unistd.h>

raster/r.horizon/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Program was refactored by Anna Petrasova to remove most global variables.
3535
#include <omp.h>
3636
#endif
3737

38+
#include <stdbool.h>
3839
#include <stdio.h>
3940
#include <stdlib.h>
4041
#include <string.h>

raster/r.kappa/print_json.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdbool.h>
12
#include <stdlib.h>
23
#include <grass/gis.h>
34
#include <grass/glocale.h>

raster/r.mask.status/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
*****************************************************************************/
1313

14+
#include <stdbool.h>
1415
#include <stdio.h>
1516
#include <stdlib.h>
1617
#include <string.h>

raster/r.out.gdal/attr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <stdbool.h>
2+
13
#include <grass/gis.h>
24
#include <grass/raster.h>
35
#include <grass/glocale.h>

raster/r.series/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*****************************************************************************/
1818

1919
#if defined(_OPENMP)
20+
#include <stdbool.h>
21+
2022
#include <omp.h>
2123
#endif
2224
#include <stdlib.h>

raster/r.slope.aspect/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#endif
2929

3030
#include <math.h>
31+
#include <stdbool.h>
3132
#include <stdlib.h>
3233
#include <string.h>
3334

raster/r.sun/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ email: hofierka@geomodel.sk,marcel.suri@jrc.it,
3737
#include <omp.h>
3838
#endif
3939

40+
#include <stdbool.h>
4041
#include <stdio.h>
4142
#include <stdlib.h>
4243
#include <math.h>

raster/r.sun/sunradstruct.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ email: hofierka@geomodel.sk,marcel.suri@jrc.it,suri@geomodel.sk
2828
/*v. 2.0 July 2002, NULL data handling, JH */
2929
/*v. 2.1 January 2003, code optimization by Thomas Huld, JH */
3030

31+
#include <stdbool.h>
32+
3133
#define EPS 1.e-4
3234
#define HOURANGLE M_PI / 12.
3335

raster/r.thin/thin_lines.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
#include <grass/glocale.h>
2020
#include "local_proto.h"
2121

22-
#define LEFT 1
23-
#define RIGHT 2
24-
25-
#define true 1
26-
#define false 0
27-
#define DELETED_PIX 9999
28-
2922
static int n_rows, n_cols, pad_size;
3023
static int box_right, box_left, box_top, box_bottom;
3124

raster/r.volume/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*
2626
*****************************************************************************/
2727

28+
#include <stdbool.h>
2829
#include <stdlib.h>
2930
#include <string.h>
3031
#include <grass/gis.h>

vector/v.db.select/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*
1919
*****************************************************************************/
2020

21+
#include <stdbool.h>
2122
#include <stdio.h>
2223
#include <stdlib.h>
2324
#include <string.h>

vector/v.fill.holes/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
****************************************************************/
1717

18+
#include <stdbool.h>
1819
#include <stdio.h>
1920
#include <stdlib.h>
2021
#include <grass/gis.h>

vector/v.hull/chull.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
not removed.
2020
--------------------------------------------------------------------
2121
*/
22+
#include <stdbool.h>
2223
#include <stdio.h>
2324
#include <stdlib.h>
2425
#include <math.h>

vector/v.surf.rst/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#if defined(_OPENMP)
2727
#include <omp.h>
2828
#endif
29+
#include <stdbool.h>
2930
#include <stdio.h>
3031
#include <stdlib.h>
3132
#include <unistd.h>

0 commit comments

Comments
 (0)