Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Feb 2009
Offline Last Active Oct 12 2016 08:02 AM

#5106683 AngelScript 2.28.0 is out

Posted by on 03 November 2013 - 08:30 AM

Hi Andreas,


you're doing a great job as always!


However, upon upgrading to AS 2.28.0 I noticed that our code doesn't compile anymore. The reason being is that starting with some later AS versions, the asSFuncPtr doesn't have implicit default constructor anymore and thus it can not be used as a member of another structure with implicit default constructor. That wouldn't be a problem if only C++ allowed initializer list to be used for classes with defined user defined constructors. And we use initializer lists a lot:

typedef struct asBehavior_s
	asEBehaviours behavior;
	const char * declaration;
	asSFuncPtr funcPointer;
	asECallConvTypes callConv;
} asBehavior_t;
static const asBehavior_t astrace_ObjectBehaviors[] =
	{ asBEHAVE_CONSTRUCT, ASLIB_FUNCTION_DECL(void, f, ()), asFUNCTION(objectTrace_DefaultConstructor), asCALL_CDECL_OBJLAST },
	{ asBEHAVE_CONSTRUCT, ASLIB_FUNCTION_DECL(void, f, (const cTrace &in)), asFUNCTION(objectTrace_CopyConstructor), asCALL_CDECL_OBJLAST },


With AngelScript 2.28 the following code doesn't compile because:


1>g_ascript.cpp(51): warning C4510: 'asBehavior_s' : default constructor could not be generated
1>          g_ascript.cpp(46) : see declaration of 'asBehavior_s'
1>g_ascript.cpp(51): warning C4610: struct 'asBehavior_s' can never be instantiated - user defined constructor required


Provinding the struct with explicit default constructor breaks initializer lists we use for the astrace_ObjectBehaviors array and the likes.


Any recommendations on what we should do? We'd rather not give up the nifty iniailizer lists, changing asFuncPtr to have implicit default constructor looks like a better option, what do you think?

asSFuncPtr(asBYTE f)


asSFuncPtr(asBYTE f = 0)