mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	documentation: update CodingStyle on local variables naming in macros
Describe proper naming convention for local variables in macros resembling functions. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									95d119528b
								
							
						
					
					
						commit
						f2027543b9
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -659,6 +659,19 @@ macros using parameters.
 | 
			
		|||
#define CONSTANT 0x4000
 | 
			
		||||
#define CONSTEXP (CONSTANT | 3)
 | 
			
		||||
 | 
			
		||||
5) namespace collisions when defining local variables in macros resembling
 | 
			
		||||
functions:
 | 
			
		||||
 | 
			
		||||
#define FOO(x)				\
 | 
			
		||||
({					\
 | 
			
		||||
	typeof(x) ret;			\
 | 
			
		||||
	ret = calc_ret(x);		\
 | 
			
		||||
	(ret);				\
 | 
			
		||||
)}
 | 
			
		||||
 | 
			
		||||
ret is a common name for a local variable - __foo_ret is less likely
 | 
			
		||||
to collide with an existing variable.
 | 
			
		||||
 | 
			
		||||
The cpp manual deals with macros exhaustively. The gcc internals manual also
 | 
			
		||||
covers RTL which is used frequently with assembly language in the kernel.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue