I would like to use some gcc warning switchs that aren’t available in older gcc versions (eg. -Wtype-limits).
Is there an easy way to check the gcc version and only add those extra options if a recent gcc is used ?
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.
I wouldn’t say its easy, but you can use the
shellfunction of GNU make to execute a shell command likegcc --versionand then use theifeqconditional expression to check the version number and set yourCFLAGSvariable appropriately.Here’s a quick example makefile:
Edit: There is no
ifgt. However, you can use the shellexprcommand to do a greater than comparison. Here’s an example