Object alignment
I've found that calling RegisterObjectType with a byteSize argument that is not a multiple of four causes an error. Is this alignment fixed, or is it variable on different platforms? Also, is it safe to pad the size argument up to the next multiple of four, or could that cause problems?
I'd kind of like to avoid adding padding directly to the c++ classes if I can avoid it..
Thanks,
~Andy
What compiler and target platform do you use?
I'll have to look into this as I'm not aware of any problems with bytes sizes non-multiple of four.
You should be able to pad the size the next multiple without any problem. The C++ compiler normally does this automatically when it allocates memory anyway, so telling AngelScript to also do this shouldn't be a problem.
Regards,
Andreas
I'll have to look into this as I'm not aware of any problems with bytes sizes non-multiple of four.
You should be able to pad the size the next multiple without any problem. The C++ compiler normally does this automatically when it allocates memory anyway, so telling AngelScript to also do this shouldn't be a problem.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Hi, thanks for getting back to me, I'd given this thread up for dead [grin].
I'm using MSVC 2005 express edition on win XP home, with version 2.7.1b of angle script.
I looked into it a bit more after my first post and the compiler isn't padding classes that only hold chars (I don't know if that is the default or not. I don't think I changed any settings, but I could be wrong). Stepping through in the debugger I found a chunk in asCScriptEngine::RegisterObjectType that checks for size equal to 1, 2 or a multiple of four. I have been padding the sizes up with no problems so far, so it looks like that could be a workable solution.
~Andy
I'm using MSVC 2005 express edition on win XP home, with version 2.7.1b of angle script.
I looked into it a bit more after my first post and the compiler isn't padding classes that only hold chars (I don't know if that is the default or not. I don't think I changed any settings, but I could be wrong). Stepping through in the debugger I found a chunk in asCScriptEngine::RegisterObjectType that checks for size equal to 1, 2 or a multiple of four. I have been padding the sizes up with no problems so far, so it looks like that could be a workable solution.
~Andy
Just a clue to your problem :
Microsoft compiler (since I use them VC5 ...) has always been packing the object's memory to 4 bytes (default value). See in project settings, C++ compiler options.
This padding can be overriden using a #pragma pack(n), where n is the byte alignment requested or by project setting.
Normaly, you use "#pragma push" and "#pragma pop" to push the compiler actual pack size and restore it to its setting.
If you include some .h files from other project than yours, there could be some #pragma pack(n) that are beeing used that you don't know about.
Hope it helps,
AbrKen.
Microsoft compiler (since I use them VC5 ...) has always been packing the object's memory to 4 bytes (default value). See in project settings, C++ compiler options.
This padding can be overriden using a #pragma pack(n), where n is the byte alignment requested or by project setting.
Normaly, you use "#pragma push" and "#pragma pop" to push the compiler actual pack size and restore it to its setting.
If you include some .h files from other project than yours, there could be some #pragma pack(n) that are beeing used that you don't know about.
Hope it helps,
AbrKen.
Sorry about the late response. I was on vacation, I had seen you're post before but didn't have the time to respond to it.
You're right, I had forgot about that validation. Actually, I can't remember anymore why I added that validation. Theoretically AngelScript shouldn't care about the size. I'll have to make some tests to see if it can be removed or what the reason for it is.
Regards,
Andreas
You're right, I had forgot about that validation. Actually, I can't remember anymore why I added that validation. Theoretically AngelScript shouldn't care about the size. I'll have to make some tests to see if it can be removed or what the reason for it is.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
No worries on the delay, it's not like this is a really major issue or anything.
Abrken, I did look into that but whatever pack pragma or /Zp options that are set, the compiler doesn't do any padding on classes that contain only chars. The sizeof() is always equal to the number of chars in the class declaration. I think it's probably the better part of valor to let it do its own thing in this case.
Thanks for the suggestion though!
~Andy
Abrken, I did look into that but whatever pack pragma or /Zp options that are set, the compiler doesn't do any padding on classes that contain only chars. The sizeof() is always equal to the number of chars in the class declaration. I think it's probably the better part of valor to let it do its own thing in this case.
Thanks for the suggestion though!
~Andy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement