-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Correction for late binding to local listener on api server #1227
Conversation
m_acceptor.bind(endpoint); | ||
m_acceptor.listen(64); | ||
} | ||
catch (const std::exception& _e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndreaLanfranchi: _e
is unreferenced here; MSVC complains about it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a very strange complaint as it's quite common standard to catch exception by reference. Do you mean it wants it by value ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just using one of MSVC's macros like UNREFERENCED_PARAMETER(_e);
should do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the directive be accepted by other compilers ? Or should I enclose it in a conditional block if _WIN32 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is MSVC specific, so we probably need to wrap it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just omit the name _e
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chfast approach is commonly used. ie. catch (const std::exception&)
Or, you can just add a "(void)_ec;" statement in the block. It doesn't generate any machine code and will satisfy the compiler. It's how you did it in K&R C.
Amends #1223