View Full Version : C Variable Types/ "#define"
matmatmat
July 24th, 2009, 02:12 PM
Is there a way to get the type of a variable?
Is there a way to use if's with defines
jespdj
July 24th, 2009, 02:15 PM
No, C does not have a standard runtime type information mechanism.
What do you mean with your second question? There's #ifdef, see Conditional Syntax (http://gcc.gnu.org/onlinedocs/cpp/Conditional-Syntax.html#Conditional-Syntax) in the GCC manual.
matmatmat
July 24th, 2009, 02:32 PM
Does that mean there is also no way to get the length of a variable?
MadCow108
July 24th, 2009, 02:35 PM
you can get the length of a varable type in bytes with sizeof(type)
but use with care when using it with arrays.
you'll mostly get the size of the pointer not the size of the array.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.