
Dear "Prodyut Hazarika",
In message 0CA0A16855646F4FA96D25A158E299D604DB40F8@SDCEXCHANGE01.ad.amcc.com you wrote:
#if defined(CONFIG_440EP) || defined (CONFIG_440GR) || \ ^^ space here ^^ space here defined(CONFIG_440EPX) || defined(CONFIG_440GR)
This is not what we are talking about. This part of the code is OK.
I want to understand why is space alignment okay here. The coding
The intention of vertical alignment is to make code look "nice". Com- puters don't care (at least to the best of my knowledge), but humans seem to find it easier if code is neatly aligned in columns.
For example, compare this example (randomly selected - it's from include/4xx_i2c.h):
(1) #define IIC_OK 0 #define IIC_NOK 1 #define IIC_NOK_LA 2 /* Lost arbitration */ #define IIC_NOK_ICT 3 /* Incomplete transfer */ #define IIC_NOK_XFRA 4 /* Transfer aborted */ #define IIC_NOK_DATA 5 /* No data in buffer */ #define IIC_NOK_TOUT 6 /* Transfer timeout */
#define IIC_TIMEOUT 1 /* 1 second */
against:
(2) #define IIC_OK 0 #define IIC_NOK 1 #define IIC_NOK_LA 2 /* Lost arbitration */ #define IIC_NOK_ICT 3 /* Incomplete transfer */ #define IIC_NOK_XFRA 4 /* Transfer aborted */ #define IIC_NOK_DATA 5 /* No data in buffer */ #define IIC_NOK_TOUT 6 /* Transfer timeout */
#define IIC_TIMEOUT 1 /* 1 second */
Which is nicer, and easier to read - (1) or (2)?
Now if you have something that starts "#if defined(..)" in the first line, then it seems only natural to me that (assuming we have to add another line, which actually is an indication of a coding problem in the first place), it should be aligned such that the "defined()" parts start in the same column. So the second line would follow like this:
#if defined(foo) ... || \ defined(bar)
There is no law, no written rule for that, just common sense and a a certain amount of esthetical sensation.
guidelines state that we must use tabs for vertical alignment. Does this rule not apply to defines? If so, the coding guidelines doc should be updated.
I'm sorry, but it would exceed my capabilities as an author to put that in writing. Feel free to add to the wiki and improve the description there yourself if you feel it needs it.
Best regards,
Wolfgang Denk