Check for command line option in my header file

Sun Jul 17 22:27:00 GMT 2016

I want to use the gcc builtin __builtin_popcount() inside my program if, and
only if, the program is compiled with the option -mpopcnt.

This is because I see that calling __builtin_popcount() when the program is
not compiled with option -mpopcnt is actually slower than doing the popcnt()
computation myself.

So I was hoping that there is a way to test whether a compilation option is
present in the preprocessor. Anyone know the answer?

View this message in context:
Sent from the gcc - Help mailing list archive at

More information about the Gcc-help mailing list