Skip to content

Win32: Guard timeapi.h include for MinGW compatibility - #1345

Merged
xuelix merged 3 commits into
FreeRTOS:mainfrom
nordync:port/win32-mingw-timeapi-fix
Dec 23, 2025
Merged

xuelix merged 3 commits into
FreeRTOS:mainfrom
nordync:port/win32-mingw-timeapi-fix

Conversation

@nordync

@nordync nordync commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

Win32 port: fix MinGW build failure caused by timeapi.h

Description

The Win32 simulator port unconditionally includes <timeapi.h>,
which is available when building with MSVC but not consistently
available when building with MinGW-w64 GCC.

This change guards the include using _MSC_VER and relies on
<mmsystem.h> for MinGW builds, restoring build compatibility
without affecting MSVC builds.

Test Steps

  1. Build FreeRTOS Win32 simulator using MSVC (no regression)
  2. Build FreeRTOS Win32 simulator using MinGW-w64 GCC
  3. Confirm successful compilation and execution

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

Fixes #1344

@aggarg

aggarg commented Dec 22, 2025

Copy link
Copy Markdown
Member

We already have this code block which includes mmsystem.h. Does it mean that we need to move #include <timeapi.h> to the #else block?

- Removed legacy GCC-specific include block.
- Added compiler-specific headers:
  - MSVC (_MSC_VER): includes <timeapi.h> and links winmm.lib
  - Other compilers: includes <mmsystem.h>
- Ensures cross-compiler compatibility and avoids duplicate headers.
@nordync

nordync commented Dec 23, 2025

Copy link
Copy Markdown
Contributor Author

We already have this code block which includes mmsystem.h. Does it mean that we need to move #include <timeapi.h> to the #else block?

Thanks for the feedback.
The previous GCC block is no longer necessary because we’ve reorganized the includes based on compiler:

_MSC_VER (MSVC) uses <timeapi.h> and links winmm.lib.

Other compilers (GCC/MinGW) use <mmsystem.h>.

This ensures cross-compiler compatibility and avoids duplicate includes. The final change removes the old GCC block entirely.

@moninom1 moninom1 changed the title bugfix/mingw-timeapi Win32: Guard timeapi.h include for MinGW compatibility Dec 23, 2025
@sonarqubecloud

Copy link
Copy Markdown

@xuelix
xuelix merged commit a9cb459 into FreeRTOS:main Dec 23, 2025
17 checks passed
@nordync
nordync deleted the port/win32-mingw-timeapi-fix branch December 24, 2025 18:49
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.

[BUG]Win32 port: timeapi.h include breaks MinGW builds (GCC)

5 participants