why ArrayDim is always 2?
define CPP_ARRAY_DIM(ArrayName, ClassName)
(sizeof(((ClassName*)0)->ArrayName) / sizeof(((ClassName*)0)->ArrayName))
I see how unreal calculate the len of an array.But why the result is always 2? I use it during UHT running.please help,thank you.
asked Jan 23 '17 at 03:53 AM in C++ Programming
UHT uses a UProperty::ArrayDim state of '2' during parsing to mean 'this property is a C array' (and '1' to mean 'TArray' and '0' to mean 'not an array'). It does not hold the actual array dimension because UHT is not an intelligent enough C++ parser to work it out in all cases.
During code generation, '2' is then translated into a
Really, this variable should be an enum. It was originally migrated from code which did attempt to parse the array dimensions, but it failed for C arrays that had anything other than a literal dimension or an enumerator in a UEnum.
Hope this aids your understanding,
answered Jan 23 '17 at 10:57 AM
Steve Robb STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here