PDA

View Full Version : Error when adding messagefunc



walfridson
07-24-2008, 02:19 AM
Got a thing I'm working on, based on the kepler (itemmotion) sample settings.

When I try to add lwmessagefunc I get these errors for some reason.
When I tried adding it to the original kepler I got the same errors. Any explanation and solution would be much appreciated. Using MS 2008 compiler.

Thanks


Error 2 error C2040: 'msgf' : 'int' differs in levels of indirection from 'LWMessageFuncs *' c:\lwsdk\sample\layout\itemmotion\kepler\kepler.c 11 kepler
Error 4 error C2099: initializer is not a constant c:\lwsdk\sample\layout\itemmotion\kepler\kepler.c 11 kepler

Code snippet, only added lwhost and the two msgf lines to the original kepler.c:


#include <lwserver.h>
#include <lwmotion.h>
#include <lwxpanel.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <lwhost.h>
LWMessageFuncs *msgf;
msgf = global( LWMESSAGEFUNCS_GLOBAL, GFUSE_TRANSIENT );

more kepler code....

evenflcw
07-24-2008, 06:30 AM
You can't call global() globally like that. There is no access to it there. You can only do it from within the activation/handler callback function which provides it.



LWMessageFuncs *msgfunc = NULL; //global declaration

XCALL_( static int )
Handler( long version, GlobalFunc *global, LWCustomObjHandler *local, void *serverData) {

msgfunc = global( LWMESSAGEFUNCS_GLOBAL, GFUSE_TRANSIENT ); //initialisation of globally accessible variable

if ( !msgfunc )
return AFUNC_BADGLOBAL;

return AFUNC_OK;
}