Skip to content

Move windows headers to port.c #1302

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

Merged
merged 3 commits into from
Aug 5, 2025

Conversation

creiter64
Copy link
Contributor

Move windows header files to port.c

Description

This prevents the inclusion of windows.h. into all header files using FreeRTOS.h and thus defining several macros conflicting with common definitions. This is a more minimal fix compared to #1282

Test Steps

None, just a build issue.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@creiter64 creiter64 requested a review from a team as a code owner July 31, 2025 06:40
@creiter64
Copy link
Contributor Author

I have removed some of the overly complicated task selection code. It would be good if someone knowledgeable could review it.

This prevents the inclusion of windows.h. into all header files using
FreeRTOS.h and thus defining several macros conflicting with common
definitions.
@creiter64 creiter64 force-pushed the upstream_remove_windows_header branch from 90edd94 to 66749ac Compare August 4, 2025 07:19
@aggarg
Copy link
Member

aggarg commented Aug 4, 2025

This prevents the inclusion of windows.h. into all header files using FreeRTOS.h and thus defining several macros conflicting with common definitions.

Would you please share the conflicting definitions?

@creiter64
Copy link
Contributor Author

Would you please share the conflicting definitions?

In my case, windows.h included winbase.h which in turn contains a macro defined as BAUD_9600, which conflicted with an enum in my code.

@aggarg
Copy link
Member

aggarg commented Aug 4, 2025

In my case, windows.h included winbase.h which in turn contains a macro defined as BAUD_9600, which conflicted with an enum in my code.

Is it not possible to change the name of this enum?

@creiter64
Copy link
Contributor Author

Is it not possible to change the name of this enum?

No. In addition I'd argue that it's bad practice to force the user to know all the ways windows.h messes with their defines on a cross-platform OS like FreeRTOS.

@aggarg
Copy link
Member

aggarg commented Aug 4, 2025

In addition I'd argue that it's bad practice to force the user to know all the ways windows.h messes with their defines on a cross-platform OS like FreeRTOS.

If you want to run your application on Windows, using a name that is used by Windows OS can lead to potential conflicts. For example, what if a future Windows update moves this define to intrin.h, which could break your application.

I assume that you have constraints preventing you from renaming the enum, but I would recommended renaming it for robustness.

@creiter64
Copy link
Contributor Author

I'm not using anything from the Windows API so I was suprised that FreeRTOS was publicly including it. The windows build is for unit testing of an embedded firmware. I try to keep that standard C compliant as possible.

@creiter64 creiter64 force-pushed the upstream_remove_windows_header branch from 66749ac to 7381ffd Compare August 4, 2025 13:17
Copy link

sonarqubecloud bot commented Aug 5, 2025

@ActoryOu ActoryOu merged commit e9440d4 into FreeRTOS:main Aug 5, 2025
17 checks passed
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.

4 participants