Skip to content

Conversation

@vrabaud
Copy link
Contributor

@vrabaud vrabaud commented Mar 28, 2025

This offers a solution to see errors like fixed in #2711

@vrabaud vrabaud requested a review from wantehchang March 28, 2025 09:06
@vrabaud vrabaud force-pushed the ci branch 3 times, most recently from 8b06b67 to a5a18f8 Compare March 31, 2025 12:55
Copy link
Collaborator

@wantehchang wantehchang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks a lot for figuring out a way to let the compiler detect this bug.

Another approach that might work is to compile the .c files as C++ code.

@vrabaud
Copy link
Contributor Author

vrabaud commented Apr 1, 2025

I thought about having a CI specific guard, but that's the only thing that would be guarded for now. We could also just use stdbool.h no? (it would not solve this problem though but it would make the code more standard)

@vrabaud
Copy link
Contributor Author

vrabaud commented Apr 1, 2025

Using stdbool actually finds other issues ... #2734
But not the ones here.

@vrabaud vrabaud marked this pull request as draft April 3, 2025 13:23
@vrabaud vrabaud force-pushed the ci branch 2 times, most recently from 6be19e0 to cface84 Compare April 4, 2025 09:18
@vrabaud vrabaud marked this pull request as ready for review April 4, 2025 09:24
@vrabaud vrabaud requested a review from wantehchang April 4, 2025 09:24
if: ${{ matrix.case == 2}}
run: |
sed -i 's/#define AVIF_TRUE 1/enum avifTrueFalse_{ AVIF_TRUE = 1,/' include/avif/avif.h
sed -i 's/#define AVIF_FALSE 0/AVIF_FALSE = 0};/' include/avif/avif.h
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we add these two alternative definitions of avifBool to avif.h and avoid patching avif.h like this. The alternative definitions would be guarded by macros that we define in this CI workflow.

If we want to patch avif.h, we may want to add comments around the definition of avifBool to prevent people form changing or even reformatting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding two guards (for stdbool and enum) is a lot of noise for a public header no? Especially just for a CI usage (not even a test).

sed -i 's/typedef int avifBool;/typedef bool avifBool;/' include/avif/avif.h
sed -i 's/#define AVIF_TRUE 1/#define AVIF_TRUE true/' include/avif/avif.h
sed -i 's/#define AVIF_FALSE 0/#define AVIF_FALSE false/' include/avif/avif.h
- name: Use enums for AVIF_TRUE/AVIF_FALSE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need this alternative definition? Does stdbool not catch all the bugs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, cf the other PR: both found different bugs .....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants