Replace exported settings globals with typed accessors - #4080
Open
paulromano wants to merge 1 commit into
Open
Conversation
paulromano
force-pushed
the
c-api-global-settings
branch
from
August 28, 2026 18:58
cf2c539 to
42e329c
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 existingopenmc.lib.settingsproperties 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 dedicatedopenmc_mainentry point within libopenmc, and the installed executable simply delegates to it. This again helps us avoid exporting global symbols just for Windows.Checklist