x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

why ArrayDim is always 2?

define CPP_ARRAY_DIM(ArrayName, ClassName)

(sizeof(((ClassName*)0)->ArrayName) / sizeof(((ClassName*)0)->ArrayName[0]))

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.

Product Version: UE 4.14
Tags:
more ▼

asked Jan 23 '17 at 03:53 AM in C++ Programming

avatar image

asqbtcupid
16 1 3 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi,

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 CPP_ARRAY_DIM() at code generation, and then the C++ compiler works out the correct value for us, as it can harness the full power of C++ parsing.

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,

Steve

more ▼

answered Jan 23 '17 at 10:57 AM

avatar image

Steve Robb STAFF
2.8k 58 31 101

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question