Why comment parameter names rather than leave it as it is

前端 未结 6 677
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 10:03

Sometimes I see code like this:

LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

Why comment pa

6条回答
  •  暖寄归人
    2021-01-02 10:17

    I think there are/were some compilers which issued a 'argument not used' warning when, well, the arguments were not used.

    Especially in message handler functions like the one you showed, the arguments are often not necessary to perform the task. So by commenting the argument names out, you could get rid of the warnings.

    On the other hand, if you later want to use some of the arguments, it's useful to have the names at hand, so commenting out is easier than just deleting the names.

提交回复
热议问题