Skip to content

Latest commit

 

History

History
126 lines (76 loc) · 3.95 KB

()-vs-(void).rst

File metadata and controls

126 lines (76 loc) · 3.95 KB

What the difference is between () and (void) and when it does matter

Part I. What the difference is

STFI

And Google will tell you.

Images/void.png

Recommended Readings

Part II. When it does matter

Besides example scenarios in the aforementioned readings, there still exist some circumstances where the difference has to be taken into consideration carefully and seriously.

Case 1. Win32 API: CallWindowProc

You know as usual, RTFM, CallWindowProc.

Especially the section Remarks, around the sentence This subtle distinction can break careless code., deserves a serious reading.

Case 2. PdbReader: Recovery of btVoid and btNoType in BasicType of DIA

In the very beginning when encoutered with btVoid and btNoType, we didn't think of this difference, notwithstanding the fact that we have understood this difference several years ago before starting PdbReader.

And before recognizing that btVoid corresponds to (void) while btNoType to (), we used __NoType__ as a temporary placeholder for btNoType, which is, however, strange and incorrect. As in Issue #1, it's the PFNCLIENT structure from win32k.sys that causes troubles.

Later, when our further investigation on PFNCLIENT and WndProc led us to CallWindowProc, it suddenly occurred to us that btNoType should correspond to ().

Conclusion

It's this very subtle and seemingly trivial distinction that leads us to writing some wrong code and producing wrong results. In fact, that's why we wrote this article and curated a list of relevant materials, which are intended to serve as takeaways for us and precautions to others.

Simply put, keep the distinction in mind and don't use () in C, unless you are 100% confident that you want the arguments unspecified, which might be useful in some cases.

As a matter of fact, it very likely that there are still many more situations where the difference can causing problems.

References