Skip to content

Conversation

@rzr
Copy link

@rzr rzr commented Mar 19, 2025

[Anders Esbensen]

Option to check arrays by the number of bytes instead of number of elements.

[Philippe Coval]

This change was applied to a fork (ths_cmock) used in a Z-Wave project. It was needed to generate mocks from a header that used annonymous structures.

The observed issue was:

(...)_mock.c:486:123: error: invalid application of ‘sizeof’ to incomplete type ‘struct (...)’

Which was just declared in relative header.

The array_as_byte feature prevent this error.

Author: Anders Esbensen [email protected]
Origin-Upstream: #503
Origin-SiliconLabs: v2.5.1-74-ga078d10
Relate-to: SiliconLabsSoftware/z-wave-protocol-controller#75

[Anders Esbensen]

Option to check arrays by the number of bytes instead of number of elements.

[Philippe Coval]

This change was applied to a fork (ths_cmock) used in a Z-Wave project.
It was needed to generate mocks from a header that used annonymous structures.

The observed issue was:

(...)_mock.c:486:123: error: invalid application of ‘sizeof’ to incomplete type ‘struct (...)’

Which was just declared in relative header.

The array_as_byte feature prevent this error.

Author: Anders Esbensen <[email protected]>
Origin-Upstream: ThrowTheSwitch#503
Origin-SiliconLabs: v2.5.1-74-ga078d10
Relate-to: SiliconLabsSoftware/z-wave-protocol-controller#75
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to rzr/z-wave-protocol-controller that referenced this pull request Mar 19, 2025
rzr added a commit to rzr/z-wave-protocol-controller that referenced this pull request Mar 19, 2025
rzr added a commit to SiliconLabsSoftware/z-wave-protocol-controller that referenced this pull request Mar 19, 2025
This not an atomic change see next patch in PR

Origin: #47
Relate-to: #60
Relate-to: #75
Relate-to: ThrowTheSwitch/CMock#503
Signed-off-by: Philippe Coval <[email protected]>
@mvandervoord
Copy link
Member

Hi @rzr -- thanks for the contribution!

I'd be interested in hearing more about your use-case. In particular, was it not possible to simply set up a treat_as for the struct type(s) to _MEMORY? I believe that would accomplish the same thing?

If this would have also worked, I'll try to improve the documentation to make this ability more clear.

Assuming that this does cover a use-case that isn't otherwise handled, there are a number of failing self-tests related to your changes to utils. Are you able to look into those or do you need me to step in?

@rzr
Copy link
Author

rzr commented Mar 24, 2025

Ok thank for feedback I will give a try to your hint soon or later.

@andersesbensen
Copy link

I did this code change years back i don’t exactly remember what this was about. I think it was became we had some structs which had an unpredictable length.

Maybe the memory check function can be used as well. But i think there was a reason I did this

rzr added a commit to rzr/z-wave-protocol-controller that referenced this pull request Apr 16, 2025
rzr added a commit to rzr/z-wave-protocol-controller that referenced this pull request Apr 16, 2025
@mvandervoord
Copy link
Member

I don't believe this is adding anything that we don't have already? I appreciate the work. Perhaps it was solving an issue that we previously had, but has since been handled other ways?

Thomasdjb pushed a commit to Thomasdjb/z-wave-protocol-controller that referenced this pull request Oct 28, 2025
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.

3 participants