-
Notifications
You must be signed in to change notification settings - Fork 41
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
Propose complete handling of records in external functions. #3198
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that will work.
This has now been test-implemented in Dymola. |
This is an interesting alternative to the void pointer solution. To make it match the fact that the void pointer approach has no restrictions when it comes to the names of record members, I suggest the following changes:
Could you also elaborate a bit on the need for allowing |
I can try to answer this one myself: Whenever Wouldn't it be better to say that the use of records always requires that the external function has an |
The first would be ok, although the 2nd reason below indicates that it may be more complicated. I would prefer to wait with the second - for two reasons:
|
The problem is that it would break compatibility with any existing code. Currently the function could have a struct with another name and in most implementations it would just work. (Especially if there is no Include.) However, I realize that one major improvement would be to have a better example. |
Honestly, this doesn't sound like existing code worth defending. Why would one want to do it that way? If needed, couldn't we look for alternative migration paths for such legacy code? |
This doesn't seem like a real problem to me. While a semicolon could do all the difference, the problem is eliminated when using a GUI to set up the record, and the consequences of getting it wrong when manually editing the annotations seem easy enough to sort out. It would just feel like an incomplete design alternative to the void pointer approach if one couldn't handle record members of any name. |
Design meeting: Another option would be to rely on the external function include to also include the struct-definitions, but we would still need CStructName. In that case the CStructName indicates that the record definition will be available through the functions' include-annotation. This means that the CStructName is only used if the external function is called. (Note that Wolfram System Modeler generates multiple source files.) |
It would be good to have this resolved, as we currently allow using records for external functions - and it sort of works, but relies on ABI-portability that compiler's generally warn for. Revisiting I think that
In C++ That's a bit annoying in C and some use typedefs and other tricks to hide this (e.g, Relying on the external function-include to provide the struct-definition seems to create odd dependencies:
If some really prefer that style we could document that an empty include-string for the record implies that it will be defined by the corresponding external function. |
Work in progress.