Will a “variableName;” C++ statement be a no-op at all times?

前端 未结 2 1510
粉色の甜心
粉色の甜心 2020-11-30 02:14

In C++ sometimes a variable will be defined, but not used. Here\'s an example - a function for use with COM_INTERFACE_ENTRY_FUNC_BLIND ATL macro:

HRESULT WIN         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 02:47

    Well, it's not really possible to say with 100% certainty without looking at the compiler's source code, but I would be very surprised if this ever generated any code in modern compilers.

    At the end of the day, if you're worried about any particular instance then you are always free to look at the generated assembly code.

提交回复
热议问题