Skip to content
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

Improve C macro style #190

Merged
merged 1 commit into from
Jan 10, 2022
Merged

Improve C macro style #190

merged 1 commit into from
Jan 10, 2022

Conversation

beutlich
Copy link
Member

@beutlich beutlich commented Jan 7, 2022

This is the preferred style for larger macro declarations and has two advantages

  • Declared local variables will be properly scoped variables then
  • It is always safe to use a trailing semicolon when macro will be called. Currently it is inconsistent for the UNUSED and CALL... macros.

@beutlich beutlich force-pushed the improve-C-macro-style branch 2 times, most recently from 7c735b5 to 9fea36d Compare January 7, 2022 20:56
@beutlich
Copy link
Member Author

beutlich commented Jan 7, 2022

Macro ASSERT_STATE seems odd to me:

  • In fmi1Functions.c the parameter A is not used at all. And there is desired side-effect by declaring S.
  • In fmi2Functions.c there is no such side-effect as S is a parameter.
  • In fmi3Functions.c there again is desired side-effect by declaring S.

I would prefer if macros do not introduce variables in the outer scope instead.

@t-sommer
Copy link
Collaborator

t-sommer commented Jan 9, 2022

@beutlich, can you please clean up the whitespace changes that are displayed in the diff?

This is the preferred style for larger macro declarations and has two advantages

* Declared local variables will be properly scoped variables then
* It is always safe to use a trailing semicolon when macro will be called
@beutlich beutlich force-pushed the improve-C-macro-style branch from 9fea36d to c63e6ca Compare January 10, 2022 06:47
@beutlich
Copy link
Member Author

@beutlich, can you please clean up the whitespace changes that are displayed in the diff?

Done.

Please note, that EOL is inconsistent for the source files, which makes it harder to contribute. All model.c files have CRLF line endings, while all other C source or header files have LF. In Modelica Standard Library we explicitly set C and H files as text, see https://github.com/modelica/ModelicaStandardLibrary/blob/master/.gitattributes

@t-sommer t-sommer merged commit e064917 into master Jan 10, 2022
@beutlich beutlich deleted the improve-C-macro-style branch January 10, 2022 10:57
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.

2 participants