| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | MSGAPI and EMX |
Hi Simeon,
SC> Why is #pragma pack(1) required? And when should it
SC> solve problems. As I say, I'm having no problems
SC> without it.
There are a lot of pointers to functions in the _msgapi structure, which are
accessed by macros. If these are not aligned correctly, some api calls will
call a garbage pointer. Not all calls depend on this, but if the structure is
not packed properly you will have problems (i.e. traps, segment violations) at
some point.
It could be that EMX has changed it's default behaviour and is packing the
structures already, if you want to check, do a test program and look at the
value that sizeof(_msgapi) returns, and compare it to the size you get by
counting up the individual data members.
e.g. (from msgapi.h)
struct _msgapi {
...
...
byte locked; /* Base is locked from use by other tasks */
byte isecho; /* Is this an EchoMail area? */
struct _apifuncs
{
sword (MAPIENTRY *CloseArea)(HAREA mh);
If this function is called, and the structure is not byte packed, it will
trap since the MSGAPI.DLL has to assume the offset of the function pointer
is where it expects it to be. With #pragma pack(1) active, the preceding
byte members will take up two bytes in the structure, with the default
packing they will take up 8 bytes, changing the offset of the function
pointer...
- Geoff
--- Maximus/2 2.02
* Origin: Low Level, Auckland, New Zealand +64-9-814-8858 (3:772/555)SEEN-BY: 620/243 622/407 623/630 632/339 640/705 670/215 690/347 711/409 410 SEEN-BY: 711/413 430 807 808 809 934 955 712/515 713/888 770/115 771/1320 SEEN-BY: 772/20 135 140 207 350 380 555 774/605 800/1 7877/2809 @PATH: 772/555 20 711/955 808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.