Browse Source

Added simple libc.sizeof<T>() function.

Mark Sibly 7 years ago
parent
commit
4f97ebf958
1 changed files with 10 additions and 0 deletions
  1. 10 0
      modules/libc/libc.monkey2

+ 10 - 0
modules/libc/libc.monkey2

@@ -77,6 +77,14 @@ Alias uintptr_t:ULong
 
 Function sizeof<T>:size_t( t:T )="sizeof"
 	
+Public
+
+Function sizeof<T>:size_t()
+	Return libc.sizeof( Cast<T Ptr>( Cast<Void Ptr>(0) )[0] )
+End
+
+Extern
+
 '***** limits.h *****
 
 Const PATH_MAX:Int
@@ -217,3 +225,5 @@ End
 Function opendir:DIR Ptr( path:CString )="opendir_utf8"
 Function readdir:dirent Ptr( dir:DIR Ptr )="readdir_utf8"
 Function closedir( dir:DIR Ptr )="closedir_utf8"
+
+Public