Sorry for the provocative title, but I’m too emotional these days.
This code:
#include#include struct tmp { int x, y, z; }; int main() { struct tmp* m_result_original=NULL; struct tmp* m_result_my_version=NULL; // m_result_original=do_something_version_1(); // m_result_my_version=do_something_version_2(); if (memcmp(m_result_original, m_result_my_version, sizeof(struct tmp)!=0)) { printf ("Error - test failed!n"); }; };
There is an unnoticed typo. in memcmp().
I wrote here:
if (memcmp(m_result_original, m_result_my_version, sizeof(struct tmp)!=0))
But must be (note closing brackets at the end):
if (memcmp(m_result_original, m_result_my_version, sizeof(struct tmp))!=0)
Yes, this is a problem of weak static typing of pure C.
Pure C