FIX: Data Alignment Switched to 4-Byte on MIPS ATL Projects (300154)



The information in this article applies to:

  • Microsoft Windows CE Platform Builder 2.12

This article was previously published under Q300154

SYMPTOMS

When you are using the Active Template Library (ATL) in a project that targets the MIPS processor, data alignment in structures is permanently switched to 4-byte instead of the default 8-byte.

CAUSE

Atlwin.h, which is included in all ATL projects, performs a #pragma pack(push,4) before the _WndProcThunk struct definition but never does the corresponding #pragma pack(pop). As a result, the data alignment is permanently switched to 4-byte throughout the project, unless explicitly changed.
...
#elif defined(_MIPS_)
#pragma pack(push,4)
struct _WndProcThunk
{
	WORD	m_pFuncHi;
	WORD	m_lui_t0;		// lui		t0,PFUNC_HIGH
	WORD	m_pFuncLo;
	WORD	m_ori_t0;		// ori		t0,t0,PFUNC_LOW
	WORD	m_pThisHi;
	WORD	m_lui_a0;		// lui		a0,PTHIS_HIGH
	DWORD	m_jr_t0;		// jr		t0
	WORD	m_pThisLo;
	WORD	m_ori_a0;		// ori		a0,PTHIS_LOW
};

#elif defined(_THUMB_)
...
				
The #pragma pack(pop) statement, which should have been placed immediately after the structure definition, is missing.

RESOLUTION

To resolve this problem, edit Atlwin.h to insert the missing line
#pragma pack(pop)
				
immediately after the _WndProcThunk structure definition, inside the #elif defined(_MPIS_) conditional block.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Platform Builder 3.0.

Modification Type:MinorLast Reviewed:12/27/2003
Keywords:kbbug kbfix KB300154