In gcc, I can write foo ? : bar which is a shorthand form of foo ? foo : bar but I see that K&R doesn’t mention it.
Is this something I should rely on, defined in some standard? Or just an (evil) gcc extension I should avoid?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a GCC extension by the name:
Conditionals with Omitted Operands.
It is not standard c.Using
-pedanticflag for compilation will tell you so.Depends on your requirements, If your code does’nt need to run on any other compiler implementation other than GCC then you can use it. However, if your code is to build on across different other compiler implementations then you should not use it.
Anyhow, One should aim to write as much intuitive and readable code as possible given that I would always suggest avoiding such (ugly)constructs.