macros

Can someone please explain this macro definition?

喜你入骨 提交于 2020-11-25 02:44:27
问题 The macro definition is as follows: #define open_listen_fd_or_die(port) \ ({ int rc = open_listen_fd(port); assert(rc >= 0); rc; }) open_listen_fd() is a function, that returns integer value. My question: What is the significance of third statement rc; ? 回答1: You're looking at a gcc extension that allows you to treat multiple statements as a single expression. The last one needs to be an expression that is used as the result of the entire thing. It's meant for use in macros to allow the

Can someone please explain this macro definition?

核能气质少年 提交于 2020-11-25 02:43:01
问题 The macro definition is as follows: #define open_listen_fd_or_die(port) \ ({ int rc = open_listen_fd(port); assert(rc >= 0); rc; }) open_listen_fd() is a function, that returns integer value. My question: What is the significance of third statement rc; ? 回答1: You're looking at a gcc extension that allows you to treat multiple statements as a single expression. The last one needs to be an expression that is used as the result of the entire thing. It's meant for use in macros to allow the