All of lore.kernel.org
 help / color / mirror / Atom feed
* Conding style question regarding configuration
@ 2019-05-28 15:47 Pascal Van Leeuwen
  2019-05-28 15:51 ` Ard Biesheuvel
  2019-05-28 16:00 ` Sandy Harris
  0 siblings, 2 replies; 9+ messages in thread
From: Pascal Van Leeuwen @ 2019-05-28 15:47 UTC (permalink / raw)
  To: linux-crypto

Hi,

Quick question regarding how to configure out code depending on a CONFIG_xxx 
switch. As far as I understood so far, the proper way to do this is not by
doing an #ifdef but by using a regular if with IS_ENABLED like so:

if (IS_ENABLED(CONFIG_PCI)) {
} 

Such that the compiler can still check the code even if the switch is 
disabled. Now that all works fine and dandy for statements within a
function, but how do you configure out, say, global variable definitions
referencing types that are tied to this configuration switch? Or should
I just leave them in, depending on the compiler to optimize them away?

Obviously the code depends on those variables again, so if it's not
done consistently the compiler will complain somehow if the switch is not 
defined ...

Also, with if (IS_ENABLED()) I cannot remove my function prototypes,
just the function body. Is that really how it's supposed to be done?

Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Inside Secure
www.insidesecure.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-06-03  7:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 15:47 Conding style question regarding configuration Pascal Van Leeuwen
2019-05-28 15:51 ` Ard Biesheuvel
2019-05-28 18:51   ` Pascal Van Leeuwen
2019-05-29 16:07     ` Christophe Leroy
2019-05-30 10:16       ` Pascal Van Leeuwen
2019-05-30 10:25         ` Ard Biesheuvel
2019-06-03  7:02         ` Christophe Leroy
2019-06-03  7:14           ` Pascal Van Leeuwen
2019-05-28 16:00 ` Sandy Harris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.