lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks for the reply.  I tried changing the padding, etc.  However, that does not seem to have an effect.  On further investigation, it is starting to look like a Windows/VC++ problem.  You see, when doing a Debug build, I am getting the assertion from _CrtIsValidHeapPointer().  In the source code for that function, it says:

/***
*int _CrtIsValidHeapPointer() - verify pointer is from 'local' heap
*
*Purpose:
*       Verify pointer is not only a valid pointer but also that it is from
*       the 'local' heap. Pointers from another copy of the C runtime (even in the
*       same process) will be caught.
*
*Entry:
*       const void * pUserData     - pointer of interest
*
*Return:
*       TRUE - if valid and from local heap
*       FALSE otherwise
*
*******************************************************************************/
_CRTIMP int __cdecl _CrtIsValidHeapPointer(
        const void * pUserData
        )
..... etc.

So it seems to be a problem with the way I am building/linking things.  Here is what I am doing:

Lua5.0 (Beta) libraries - Compiled into a static library (lua.lib, luaD.lib) - luaD.lib is the Debug version
MyApplication - Includes the lua .h files and lua.lib and luaD.lib
ExtensionDLL - Includes the lua .h files and lua.lib and luaD.lib - this is the extension library loaded using loadmodule.c

Everything is compiled with "Multithreaded Debug" and "Multithreaded" under the "Use run-time library" field in Project > Settings > C/C++ > Code Generation tab in VC++.

Does anyone out there have experience doing something similar in Windows with VC++?  Is it possible that my problems stem from using Lua as a static library?  Would it be better to use it as a DLL?

Thanks again to all of the help so far and to all in this community who take the time to help out.

Regards,

Brett Kapilik

> -----Original Message-----
> From: Bilyk, Alex [mailto:ABilyk@maxis.com]
> Sent: Friday, March 07, 2003 8:56 PM
> To: Multiple recipients of list
> Subject: RE: Lua 5.0 beta/loadmodule question
> 
> 
> 
> 
> > -----Original Message-----
> > From: Eero Pajarre [mailto:epajarre@koti.tpo.fi]
> > Sent: Friday, March 07, 2003 11:57 AM
> > To: Multiple recipients of list
> > Subject: Re: Lua 5.0 beta/loadmodule question
> > 
> 
> [skipped]
> 
> > I am pretty sure that sizeof(tbl)/sizeof(tbl[0]) is a safe 
> > C/C++ idiom.
> > C/C++ arrays don't contain "gaps", if padding is needed it 
> is already
> > inside the structs.
> 
> This padding, however, may differ from module to module 
> resulting in all sorts of trouble when passed around 
> carelessly. Though it remains to be seen whether the problems 
> reported by original poster relate in any way to data alignment. 
> 
> [skipped]
>  
> > 
> > 		Eero
> 
> Alex
>