Skip to content

stdint.h: make redefinition of stdint types optional #19912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mnkp
Copy link
Member

@mnkp mnkp commented Oct 18, 2019

PR #16645 streamlined stdint.h type definitions. This has an unfortunate side effect that any legacy code which assumed default, compiler provided types will now generate warnings any time type mismatch is detected during the compilation process. Redefining stdint types also significantly increases porting effort when building an existing bare metal application with Zephyr.

This PR makes redefinition of stdint types optional.

I wasn't sure if the Kconfig option should go into "C library" or "Compiler Options" sub menu. For now it's in the "C library".

PR zephyrproject-rtos#16645 streamlined stdint.h type definitions. This has an unfortunate
side effect that any legacy code which assumed default, compiler
provided types will now generate warnings any time type mismatch is
detected during the compilation process. Redefining stdint types also
significantly increases porting effort when building an existing
bare metal application with Zephyr.

This PR makes redefinition of stdint types optional.

Signed-off-by: Piotr Mienkowski <[email protected]>
@mnkp mnkp requested a review from npitre October 18, 2019 07:47
@jhedberg jhedberg requested a review from galak October 18, 2019 07:48
@SebastianBoe SebastianBoe removed their request for review October 18, 2019 09:47
@npitre
Copy link
Collaborator

npitre commented Oct 18, 2019 via email

@mnkp
Copy link
Member Author

mnkp commented Oct 20, 2019

Let me explain my case in a bit more detail. We have built an SDK in form of a bare metal application that we use internally and provide also to third parties so they can build their products using our solution. It runs using standard gcc build process. We have another version of the SDK which is build as a Zephyr application. It provides some extra functionality like firmware over the air update (using mcuboot as a bootloader) and shell subsystem. With time we plan to move completely to Zephyr but this is not the case yet. This is a valid use case. Since #16645 was merged I had to manually patch Zephyr code base every time when making a release, I wouldn't like to do it any more. No need to say, our bare metal SDK version is using fully valid C syntax and builds clean. Without patching Zephyr the same code generates tons of warnings.

The only sane way to have an OS like Zephyr that aspires to be highly portable without making the code (both the OS itself and existing apps) is to enforce consistent types across architectures and bus sizes.

This is true, however not applicable to this discussion since stdint types are not allowed in Zephyr code base. Zephyr defines its own set of fixed size types u32_t, u16_t and alike. Had Zephyr been using stdint types then indeed the solution proposed in this PR would not be viable.

At the moment stdint types are fully reserved for the applications that are build on top of Zephyr and there is no need to artificially restrict those. Not everyone writes code that aims to be portable across architectures.

Current approach also puts much higher burden on anyone who has existing legacy code and would like to run it as a Zephyr application. It can impact acceptance of Zephyr as a go to solution.

I'm not asking to revert #16645, that's good work, I'm happy we have it. All I'm asking for is to give users an option to build their applications using stdint types as defined by the compiler. The default behavior remains as is.

@npitre
Copy link
Collaborator

npitre commented Oct 23, 2019 via email

@mnkp
Copy link
Member Author

mnkp commented Jun 13, 2020

By merging #25679 we moved to using stdint types natively in the Zephyr tree. This PR is no longer applicable. Closing.

@mnkp mnkp closed this Jun 13, 2020
@mnkp mnkp deleted the cstdint branch June 13, 2020 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants