Skip to content

[C] adding nodiscard for CoSimIO_Info#181

Merged
philbucher merged 5 commits intomasterfrom
c/nodiscard
May 26, 2021
Merged

[C] adding nodiscard for CoSimIO_Info#181
philbucher merged 5 commits intomasterfrom
c/nodiscard

Conversation

@philbucher
Copy link
Copy Markdown
Member

I found a way to emulate nodiscard in C :) (with GCC and clang)
Apparently it will be added in C23: https://en.cppreference.com/w/c/language/attributes/nodiscard

this is how the warning message looks like:

home/philipp/software/CoSimIO/tests/integration_tutorials/c/export_mesh.c:87:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    CoSimIO_CreateInfo();

I would say this is better than manually keeping track of the CoSimIO_Info, what do you think @pooyan-dadvand ?

Changelog:

- creating CO_SIM_IO_NODISCARD to warn when memory is leaked from CoSimIO_Info

@philbucher philbucher changed the title C/nodiscard [C] adding nodiscard for CoSimIO_Info May 25, 2021
@philbucher
Copy link
Copy Markdown
Member Author

now seems to work fine :)

Copy link
Copy Markdown
Member

@pooyan-dadvand pooyan-dadvand left a comment

Choose a reason for hiding this comment

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

A good hint for developers!

@philbucher philbucher merged commit b12bd32 into master May 26, 2021
@philbucher philbucher deleted the c/nodiscard branch May 26, 2021 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants