[Q-e-developers] Pre-processor macro code style

Filippo SPIGA filippo.spiga at quantum-espresso.org
Sun Sep 11 18:55:13 CEST 2016


Hi all,

if you browse the entire QE source code (my favorite Sunday afternoon hobby) you will notice that pre-processor macros are used in multiple places and with different code styles. A bit of a mess. I am able to spot three popular cases:

1) #ifdef __X

2) #if defined __X

3) #if defined(__X) 


Style number (3) is the most versatile one. It is clear, it carries no ambiguity and the "#if" statement can be combined with comparison expressions e.g. " #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER  >= 1300) ", something very useful to avoid nested multiple #if-#endif!  Number (1), the most popular one, cannot do such thing unless multiple "#if" are used.

During the next week, package by package, I will transform all (1) and (2) occurrences into (3). Every time I am ready to commit changes I will warn everyone in advance via this mailing-list. Because these are very isolated changes that involve single lines at a time, I expect SVN to be able to cope and merge them directly into your working directory. 

I will target only the core packages (pw ph pp pwcond neb cp ld1 upf tddfpt gwl couple). Third-party packages can adopt whatever style they want but it will be cool if everything is consistent across all QE-related codes.

Cheers

--
Filippo SPIGA ~ Quantum ESPRESSO Foundation ~ http://www.quantum-espresso.org





More information about the developers mailing list