mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	util: use C23 typeof if available
Instead of using the non-standard __typeof__, prefer the standard typeof operator introduced in C23. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
		
							parent
							
								
									dc1da181db
								
							
						
					
					
						commit
						56b9c92b98
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -68,6 +68,12 @@ extern "C" {
 | 
				
			||||||
#define WL_PRINTF(x, y)
 | 
					#define WL_PRINTF(x, y)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if __STDC_VERSION__ >= 202311L
 | 
				
			||||||
 | 
					#define WL_TYPEOF(expr) typeof(expr)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define WL_TYPEOF(expr) __typeof__(expr)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** \class wl_object
 | 
					/** \class wl_object
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * \brief A protocol object.
 | 
					 * \brief A protocol object.
 | 
				
			||||||
| 
						 | 
					@ -406,8 +412,8 @@ wl_list_insert_list(struct wl_list *list, struct wl_list *other);
 | 
				
			||||||
 * \return The container for the specified pointer
 | 
					 * \return The container for the specified pointer
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#define wl_container_of(ptr, sample, member)				\
 | 
					#define wl_container_of(ptr, sample, member)				\
 | 
				
			||||||
	(__typeof__(sample))((char *)(ptr) -				\
 | 
						(WL_TYPEOF(sample))((char *)(ptr) -				\
 | 
				
			||||||
			     offsetof(__typeof__(*sample), member))
 | 
								     offsetof(WL_TYPEOF(*sample), member))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Iterates over a list.
 | 
					 * Iterates over a list.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue