Software Archive
Read-only legacy content
17061 Discussions

pxcCHAR explanation

Scott_W_1
Beginner
723 Views

Could someone explain the rationale behind using pxcCHAR to store hand and finger data?

It proves tricky to work around pxcCHAR instead of just CHAR, but if there's a good reason... I'm all for it. 

I'm about to convert an array of type pxcCHAR to a dynamically sized array. Any explanations of pxcCHAR would be helpful.

 

0 Kudos
3 Replies
Alain_Labrie
Beginner
723 Views

pxcCHAR  is a typedef for wchar_t.

 

Wide characters (wchar_t)  are used to support languages with more than 256 characters. Whereas char = 8bit = 256 character limit.

wchar_t size is compiler dependent so be careful when allocating dynamic arrays.

0 Kudos
Scott_W_1
Beginner
723 Views

Thanks!

Here's the reason for thinking about creating a dynamic array:

I'm recording gesture parameters. When I first started, the pxcCHAR array was set to a size of 1000. It worked fine for recording one frame of a single parameter and displaying it in an edit box control. The parameter was local rotations of the finger joints. As soon as I added another parameter, the entire app crashed. I fixed it by setting the array size to 50000 (Probably overkill), but there may be times that I simply cannot predict the size of the array. 
 
Any suggestions?
 
Scott
0 Kudos
Alain_Labrie
Beginner
723 Views

I would use an STL container like a vector and push data onto it. Then I would clear it when the data is no longer needed.

If you allocate your own data structure, remember that pxcCHAR is a wide character with compiler dependent size. So if you need to figure out how much memory your structure is consuming you have to do:

int size = sizeof(buffer)/sizeof(pxcCHAR) 

where buffer is your pxcCHAR array.

 

Good Luck

0 Kudos
Reply