• 16
• 15
• 12
• 9
• 10

Private class functions that return a type other than "void."

This topic is 2157 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm working within the Amnesia HPL2 engine, so this may just be a problem with the engine (though I can't really see how as the engine is based on Angelscript, but it's proabablly important to mention), but whenever I try to include private class functions that aren't of the type "void" it gives me a compile error: "ERR : Can't return value when return type is 'void'"

For example, the function:
 private int ABS(int i) { if(i <= 0) return (-1 * i); else return i; } 
inside of a class returns the error mentioned above when called (from a public function within the class of course).

Is there any reason why it is doing this, or are private functions of any type other than "void" not supported? The page in the AngelScript manual about private functions ( http://www.angelcode...ss_private.html )doesn't say anything against this, so I don't see why this shouldn't be allowed. I know I can get around it by using refrence peramaters, but that can get a bit obnoxious in a lot of cases.

Share on other sites
Hi Satsu,

you're right. This was a bug in AngelScript.

It has already been fixed a long time ago, but Amnesia probably don't use the latest version of AngelScript, thus don't include the bug fix.

I suggest you get in touch with Frictional Games and let them know about this bug in AngelScript, so they can provide a patch for the HPL2 engine and Amnesia. If they need my help to identify what needs to be modified for the version of AngelScript that they are using I'll gladly do so.

Regards,
Andreas

Share on other sites
Ah, that makes a lot of sense then. I was pretty confused, as I couldn't really see how a bug like that could have gone by unnoticed. >_<

Thanks a lot!