Changeset - r15062:3ce4d3cd6f51
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-04-23 14:56:14
rubidium@openttd.org
(svn r19698) -Add: macros to get the size/length of a variable within a class
1 file changed with 16 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/stdafx.h
Show inline comments
 
@@ -371,6 +371,22 @@ assert_compile(sizeof(uint8)  == 1);
 
	#define offsetof(s, m) cpp_offsetof(s, m)
 
#endif /* offsetof */
 

	
 
/**
 
 * Gets the size of a variable within a class.
 
 * @param base     The class the variable is in.
 
 * @param variable The variable to get the size of.
 
 * @return the size of the variable
 
 */
 
#define cpp_sizeof(base, variable) (sizeof(((base*)8)->variable))
 

	
 
/**
 
 * Gets the length of an array variable within a class.
 
 * @param base     The class the variable is in.
 
 * @param variable The array variable to get the size of.
 
 * @return the length of the array
 
 */
 
#define cpp_lengthof(base, variable) (cpp_sizeof(base, variable) / cpp_sizeof(base, variable[0]))
 

	
 

	
 
/* take care of some name clashes on MacOS */
 
#if defined(__APPLE__)
0 comments (0 inline, 0 general)