Issue with NULL pointers on Harvard Architecture platform

前端 未结 6 966
醉话见心
醉话见心 2021-01-17 08:59

Interesting issue we came across here this week.

We are working in C on a Harvard Architecture embedded platform, which has 16-bit data addresses and 32-bit code add

6条回答
  •  心在旅途
    2021-01-17 09:13

    The way you describe should work:

    6.3.2.3/3 An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant. If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.

    So, either NULL has been redefined to something not 0 or (void*)0 (or equivalent?) or your compiler is non-conformant.

    Try redefining NULL yourself (to plain 0) after all the #includes in all files :-)

    just for kicks: try gcc -E (to output the preprocessed source) on a problem file and check the expansion of NULL

提交回复
热议问题