Skip to content

Commit da6062e

Browse files
committed
Fixes according to comments and add CI
1 parent eef44ef commit da6062e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.github/workflows/ci-c-warnings.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
# Generate the configurations:
19-
# case 0: nodiscard
19+
# case 0: nodiscard, case 1: use stdbool, case 2: use enums
2020
matrix:
2121
os: [ubuntu-latest, windows-latest]
22-
case: [0]
22+
case: [0, 1, 2]
2323

2424
runs-on: ${{ matrix.os }}
2525

@@ -53,6 +53,18 @@ jobs:
5353
- name: Enable nodiscard
5454
if: ${{ matrix.case == 0}}
5555
run: echo "CMAKE_AVIF_FLAGS=\"-DAVIF_ENABLE_NODISCARD=ON\"" >> $GITHUB_ENV
56+
- name: Use stdbool for AVIF_TRUE/AVIF_FALSE
57+
if: ${{ matrix.case == 1}}
58+
run: |
59+
sed -i 's/#include <stdint.h>/#include <stdint.h>\n#include <stdbool.h>/' include/avif/avif.h
60+
sed -i 's/typedef int avifBool;/typedef bool avifBool;/' include/avif/avif.h
61+
sed -i 's/#define AVIF_TRUE 1/#define AVIF_TRUE true/' include/avif/avif.h
62+
sed -i 's/#define AVIF_FALSE 0/#define AVIF_FALSE false/' include/avif/avif.h
63+
- name: Use enums for AVIF_TRUE/AVIF_FALSE
64+
if: ${{ matrix.case == 2}}
65+
run: |
66+
sed -i 's/#define AVIF_TRUE 1/enum avifTrueFalse_{ AVIF_TRUE 1,/' include/avif/avif.h
67+
sed -i 's/#define AVIF_FALSE 0/AVIF_FALSE 0};/' include/avif/avif.h
5668
5769
- name: Prepare libavif (cmake)
5870
run: >

include/avif/avif.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ extern "C" {
8585
((AVIF_VERSION_MAJOR * 1000000) + (AVIF_VERSION_MINOR * 10000) + (AVIF_VERSION_PATCH * 100) + AVIF_VERSION_DEVEL)
8686

8787
typedef int avifBool;
88-
typedef enum avifTrueFalse
88+
enum avifTrueFalse_
8989
{
9090
AVIF_FALSE = 0,
9191
AVIF_TRUE = 1
92-
} avifTrueFalse;
92+
};
9393

9494
#define AVIF_DIAGNOSTICS_ERROR_BUFFER_SIZE 256
9595

include/avif/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static inline void avifBreakOnError()
6969
} while (0)
7070
#else
7171
#define AVIF_ASSERT_OR_RETURN(A) assert(A)
72-
#define AVIF_ASSERT_NOT_REACHED_OR_RETURN assert(AVIF_FALSE);
72+
#define AVIF_ASSERT_NOT_REACHED_OR_RETURN assert(0);
7373
#endif
7474

7575
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)