Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
TorKlingberg
on Feb 26, 2016
|
parent
|
context
|
favorite
| on:
GCC 6: -Wmisleading-indentation vs. “goto fail;”
How would you use the ternary operator there? Like this?
image ? foo_release(image) : 0;
dcvuob
on Feb 26, 2016
[–]
Yes. And cast that 0 to (void), so the compiler won't complain over an unused expression.
Any C programmer will recognize what (void)0 means, do nothing.
TorKlingberg
on Feb 26, 2016
|
parent
[–]
Sure, but I find it strange to use the ternary operator and discarding the value. It's not wrong, but I think most C programmers prefer a simple if statement.
dcvuob
on Feb 26, 2016
|
root
|
parent
[–]
I was giving an replacement for the if statement presented above, where both expressions are on the same line.
Consider applying for YC's Spring batch! Applications are open till Feb 11.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: