-
Notifications
You must be signed in to change notification settings - Fork 940
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
gcc warning: cast from function call of type ‘TEST_error_t’ to non-matching type ‘long long int’ #67
Comments
Interesting. I admit that I'm a little puzzled by this. As I was reading through your example, I was pretty sure that the problem was going to be that your typedef was not in an #include that was visible to the function under test or something like that... but I'm not sure that makes sense now that I have read it all. I suspect it has something to do with the size of the enum. Clearly, a long long int is much bigger than your enum needs to be. Depending on the gcc target, that enum might be a byte or it might be an int (I think those are the most common). Either way, you're getting a mismatch in the size you are comparing vs the size you are passing. It still seems like it should handle this without complaint for you, but breaking the casts into two steps by giving it a temporary variable seems to make it happier. Out of curiosity, have you tried using a specific int size instead of the general assertion? TEST_ASSERT_EQUAL_HEX8 or TEST_ASSERT_EQUAL_HEX32 maybe? Mark |
Hi Mark, yeah I've tried to use the TEST_ASSERT_EQUAL_HEX8 and the TEST_ASSERT_EQUAL_HEX32, but is won't help. I've checked size of the plain integer on my platform as well as size of enum. It seems that those both sizes are equal 4. Right now I don't get it why gcc rises warning for such a construction, and I'd like to investigate this further. Please let me know do you have any idea why is it not working. |
Wow. I forgot to come back to this one. I apologize if anyone was actually waiting on a good response here. Giving it some thought, to those who might run into this in the future, I suspect it's that there wasn't a declaration for the function anywhere in the test (or in a header the test included). If it had been added, like so: extern TEST_error_t TEST_fnc(void); I bet the error would have gone away. I suspect the problem was that without the function declaration being there, gcc assumed the return value was the biggest int it could... which then didn't fit into the ASSERT. |
Hi,
I've encountered some issue by testing my code, I got some function which definition looks like this :
Then in my test I'm trying to test value which returns the
TEST_fnc()
by invoking following code:GCC throws me a warning then that :
,when I'm testing return value from the function like this, warning disappears
I'm working on the 64-bit system, could you please tell am I doing something wrong ?
The text was updated successfully, but these errors were encountered: