Continuing toward Windows support — this PR is aimed at avoiding the need for Windows-specific exports (similar to #4065). In this case, the Python bindings currently read and write mutable OpenMC settings directly with ctypes.in_dll, which requires implementation details to be exported from the shared library. This change replaces those data accesses with name-based C API getter and setter pairs for boolean, 32-bit integer, 64-bit integer, and double settings, along with a read-only string getter. An alternative would be to have a get/set pair for each setting specifically, but that has the downside of requiring more functions in the long term. This design allows us to handle future settings without introducing new C API functions. The existing openmc.lib.settings properties remain unchanged for users while their ctypes implementation is reduced to one accessor pair per datatype.
One other change I made here is to move the body of int main() into a dedicated openmc_main entry point within libopenmc, and the installed executable simply delegates to it. This again helps us avoid exporting global symbols just for Windows.
Checklist
I have performed a self-review of my own code
I have run clang-format (version 18) on any C++ source files (if applicable)
I have followed the style guidelines for Python source files (if applicable)
I have made corresponding changes to the documentation (if applicable)
I have added tests that prove my fix is effective or that my feature works (if applicable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Continuing toward Windows support — this PR is aimed at avoiding the need for Windows-specific exports (similar to #4065). In this case, the Python bindings currently read and write mutable OpenMC settings directly with ctypes.in_dll, which requires implementation details to be exported from the shared library. This change replaces those data accesses with name-based C API getter and setter pairs for boolean, 32-bit integer, 64-bit integer, and double settings, along with a read-only string getter. An alternative would be to have a get/set pair for each setting specifically, but that has the downside of requiring more functions in the long term. This design allows us to handle future settings without introducing new C API functions. The existing openmc.lib.settings properties remain unchanged for users while their ctypes implementation is reduced to one accessor pair per datatype.
One other change I made here is to move the body of int main() into a dedicated openmc_main entry point within libopenmc, and the installed executable simply delegates to it. This again helps us avoid exporting global symbols just for Windows.
Checklist