-
Notifications
You must be signed in to change notification settings - Fork 274
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
Mock function declaration swaps function argument array for pointer #422
Comments
I've just been hit with this as well, and it's definately something that cmock does. A simple example to replicate is attached and written below: foo.zip contains foo.h:
On a command line run:
And you will get this generated in "Mockfoo.c":
Which then causes a compiler warning with gcc. It seems to be done in CMock/lib/cmock_header_parser.rb, line 479-480, but I assume there would be many knock on effects if you changed it away from converting arrays to pointers. I haven't tried, I don't know enough ruby.:
This already seems to be reported in #69, but that specifically mentions multidemensional arrays but I assume it happens for any arrays. |
Hi. I'm going to admit something here. We took a shortcut WAaaaaaaaaay back when we wrote CMock. We said "internally, arrays and pointers are the same thing... and internally multidimensional arrays are just single dimension arrays accessed differently." It was a hack and it was meant to get to version 1 and then get fixed. Then it didn't get fixed. For a long time. And I feel embarrassed and I deeply apologize for how long we've let that slide. This is an issue that should have been fixed a long long time ago. It's not a hard problem to solve. It IS a nuanced problem. That means that I know that when I start working on it, it's going to require a time investment to do it right. And it's worth doing it right. So far that's kept me from tackling it in my slivers of free time. I intend to change that pattern soon. Hopefully I'm not adding words here that I will further regret. ;) |
Note that in this particular case, you can try |
I am trying to mock an esp-idf component with CMock and the build is failing due to a mismatch in function definition from a
const uint8_t[6]
in the original header to aconst uint8_t[6]
in the mock header. Have I missed something or does CMock not handle this case correctly?I'm not 100% sure if this is an issue on the CMock or esp-idf side. If you think it is not CMock, let me know and I'll open a ticket on esp-idf
The text was updated successfully, but these errors were encountered: