Skip to content

Make Windows (MinGW G++) compatible#445

Open
andrewxu319 wants to merge 25 commits into
developfrom
andrew/windows-compatibility
Open

Make Windows (MinGW G++) compatible#445
andrewxu319 wants to merge 25 commits into
developfrom
andrew/windows-compatibility

Conversation

@andrewxu319

Copy link
Copy Markdown
Collaborator

Description

Make compiler-specific changes such that GridKit runs and pass all tests on Windows. Specifically, it now works with MinGW G++, but not MSVC.

Please describe the issue that is addressed (bug, new feature,
documentation, enhancement, etc.). Please also include relevant motivation and
context. List any dependencies that are required for this change.

Closes #(issue)

Mentions @(user)

Proposed changes

Describe how your changes here address the issue and why the proposed changes
should be accepted.

  • Append .string() to .filename() to extract the underlying string if the OS is Windows
  • Replace __attribute__((always_inline)) inline with a compiler-specific FORCE_INLINE macro
  • Inline toUpper() to avoid compiler errors

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here
to help! This is simply a reminder of what we are going to look for before
merging your code.

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining
why you chose the solution you did and what alternatives you considered, etc...

@andrewxu319 andrewxu319 requested a review from pelesh June 10, 2026 13:41
andrewxu319 and others added 2 commits June 10, 2026 13:41
* Fix phasor_dynamics_systemmodel targets.

---------

Co-authored-by: nkoukpaizan <nkoukpaizan@users.noreply.github.com>
Comment thread README.md Outdated
```powershell
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install -DBUILD_SHARED_LIBS=OFF ../

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are different instructions really needed? The only difference I see with the earlier instructions is DBUILD_SHARED_LIBS=Off. I would recommend implementing a workaround for that in CMake instead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe not. Removed it for now. However I did also need to specify the directory ../ instead of ../GridKit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

../GridKit is suggested for out-of-source builds, with the build and GridKit directories being at the same level in the file structure.

@nkoukpaizan

Copy link
Copy Markdown
Collaborator

re 5ffbf8d: I recommend rebasing (git rebase) rather than merging (git merge). That should fix most of the testing issues.

@andrewxu319

Copy link
Copy Markdown
Collaborator Author

re 5ffbf8d: I recommend rebasing (git rebase) rather than merging (git merge). That should fix most of the testing issues.

Rebase done.

@pelesh pelesh requested a review from superwhiskers June 12, 2026 18:01

@superwhiskers superwhiskers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i don't have a windows machine to test this on

#elif defined(_MSC_VER)
#define FORCE_INLINE [[msvc::forceinline]] inline
#else
#define FORCE_INLINE __attribute__((always_inline)) inline

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if you used the standard syntax for attributes, such as [[gnu::always_inline]] instead of __attribute__((always_inline)), this macro wouldn't be necessary as you could write [[msvc::forceinline, gnu::always_inline]].

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

at least, in my testing w/ clang, clang ignores the msvc::forceinline, raising a warning but compiles just fine. perhaps msvc doesn't like seeing gnu::always_inline, but that would be weird. could just ignore that warning via flags or something like that to reduce noise. alternatively, keep the conditional macro but using the standard syntax anyway.

* @brief Convert a string to all uppercase
*/
std::string toUpper(std::string str)
inline std::string toUpper(std::string str)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what compiler error warranted this?

Comment thread CHANGELOG.md
- Added off-nominal tap ratio and phase shift support to the PhasorDynamics `Branch` model.
- Added portable Vector class to GridKit
- Added portable Vector class to GridKit.
- Added Windows compatibility.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

specify it's mingw g++ only or list caveats with msvc. also consider testing llvm on windows as well (uncommon, but would allow enzyme to work, maybe).

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