12/02/2005
Lessons learned
There are two experiences I would like to share to avoid anyone to reproduce some of my previous misunderstanding.
Ansi and Unicode on a PocketPC
Documentation on the Web about “porting an application to PocketPC” will say that a PocketPC needs to work in Unicode.The difference between Ansi and Unicode is that a character is coded with one byte for Ansi whereas it is coded with two bytes for Unicode. With other words, considering that “char” are Ansi characters and “wchar_t” are Unicode characters, sizeof(char) = 1 whereas sizeof (wchar_t) =2. The impact on memory allocation is that you will need to add sizeof (wchar_t) everywhere sizeof(char) is implicitly used. For example, to allocate memory, you will need to write:
variable = (wchar_t*)malloc(length * sizeof(wchar_t)).
You could think: “Ah! That’s why my application is crashing! PocketPC works in Unicode and my memory allocations are wrong!”.
After some investigations, you will easily draw an overall picture about differences between Ansi and Unicode: e.g. “char” have to be declared “wchar_t”, str* functions have to be replaced by their wcs* equivalent functions, you will also probably find a sexy list of differences summarizing all you need.
And you will begin to convert all Blender source code in Unicode. And as soon as you will arrive to the famous Blender guardedalloc library, it will be the end of the story… Even the Dutch comments will not help you :=) You will then realize that you have no chance to succeed ( Ton words!).
All this lost energy comes from a misunderstanding of the sentence “PocketPC needs to work in Unicode”. PocketPC can work as you like, it can even run Linux! But if you use the Microsoft API, then you have to provide only Unicode parameters. But only for these API functions (e.g. createwindow). The good news is that Blender isolation of platform specific stuff will make your life easier. You will only need to make the Ansi/Unicode conversion locally as soon as a Microsoft API function is needed.
That’s all.
After some investigations, you will easily draw an overall picture about differences between Ansi and Unicode: e.g. “char” have to be declared “wchar_t”, str* functions have to be replaced by their wcs* equivalent functions, you will also probably find a sexy list of differences summarizing all you need.
And you will begin to convert all Blender source code in Unicode. And as soon as you will arrive to the famous Blender guardedalloc library, it will be the end of the story… Even the Dutch comments will not help you :=) You will then realize that you have no chance to succeed ( Ton words!).
All this lost energy comes from a misunderstanding of the sentence “PocketPC needs to work in Unicode”. PocketPC can work as you like, it can even run Linux! But if you use the Microsoft API, then you have to provide only Unicode parameters. But only for these API functions (e.g. createwindow). The good news is that Blender isolation of platform specific stuff will make your life easier. You will only need to make the Ansi/Unicode conversion locally as soon as a Microsoft API function is needed.
That’s all.
Data misalignment exception
Another error that was really time consuming was a “Data misalignment exception”. As soon as you will encounter this error, you could check what does “Data alignment” mean. It will be very interesting because you will discover that embedded system (with ARM processor) are very sensitive to data alignment. You will also discover that Blender as a fantastic management of data alignment to assure portability. Looking for a solution of your “data misalignment” problem, there is a big chance that you are forced to better understand what SDNA are in Blender, what you are able and not able to do.
To solve this error, I was forced to generate properly dna.c from my PocketPC what is a good point.
But after all this adventure, you will probably discover that this “Data misalignment exception” is only on of you bad memory allocation. Nothing more.
No need to take a bazooka to kill a fly :=)
To solve this error, I was forced to generate properly dna.c from my PocketPC what is a good point.
But after all this adventure, you will probably discover that this “Data misalignment exception” is only on of you bad memory allocation. Nothing more.
No need to take a bazooka to kill a fly :=)
11:10 Posted in 4 - Lessons learned | Permalink | Comments (0) | Email this