Skip to content

Conversation

@XinStellaris
Copy link
Contributor

Summary

littlefs is a c99 project, and it malfunctions with c89. See disscusion in littlefs-project/littlefs#801.

To highlight this problem, littlefs added an assert in littlefs-project/littlefs#801.
However, it is better to expose this when compiling. This patch adds a compiling error when C99 requirement is not met.

Impact

Littlefs

Testing

Compiling okay.

@pkarashchenko
Copy link
Contributor

Can we either add CFLAGS += -std=c99 if C99 is a prerequisite or apply patch after tarball download to get it c89 compatible?

Copy link
Contributor

@pkarashchenko pkarashchenko left a comment

Choose a reason for hiding this comment

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

I re-inspected the code of littlefs and see that CFLAGS += -std=c99 is a must and code has designated initialiser, variable declaration in the middle of the scope and other C99 features.

@xiaoxiang781216
Copy link
Contributor

Can we either add CFLAGS += -std=c99 if C99 is a prerequisite or apply patch after tarball download to get it c89 compatible?

-std=c99 is tool chain specific, it isn't good to turn on it in the common code.

@pkarashchenko
Copy link
Contributor

But the littlefs code is anyway C89 in compliant no matter of a toolchain.
I just saw that CONFIG_C99_BOOL is selected based on __STDC_VERSION__ , so I'm fine with the change now.

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#  define CONFIG_C99_BOOL 1
#endif

@xiaoxiang781216
Copy link
Contributor

Yes, I think it's enough to warn the user if they enforce c89 accidently.

Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

Telling them why and what to do about would be better.

@XinStellaris XinStellaris force-pushed the lfs_must_c99 branch 2 times, most recently from a2b8d5d to e04124d Compare April 18, 2023 12:15
@davids5 davids5 requested a review from gustavonihei April 18, 2023 17:24
@davids5 davids5 merged commit 770817b into apache:master Apr 18, 2023
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.

5 participants