• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [solved] Strange warning when using YYC

funkygallo

Member
Ok
I have this function
Code:
///sin_oscillate(min,max,position)
return((argument[1]-argument[0])/2 * dsin(argument[2]) + (argument[1]+argument[0])/2);
when compiling with yyc i have this warning
Code:
Z:/prj1_D2CE6B5B/totre/default/Scripts/llvm-win/gml_Script_scp_sin_oscillate.gml.cpp:19:23: warning: multiple unsequenced modifications to '_yytmp_' [-Wunsequenced]
_result = (((((*_args[YY_CHECK_ARG_RANGE((int)(1), _count)]) - (*_args[YY_CHECK_ARG_RANGE((int)(0), _count)])) / (double)2) * YYGML_CallLegacyFunction(pSelf,pOther,__ret1__,1,g_FUNC_dsin.val,__pArg3__)) + (((*_args[YY_CHECK_ARG_RANGE((int)(1), _count)]) + (*_args[YY_CHECK_ARG_RANGE((int)(0), _count)])) / (double)2));
                      ^                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X://yyc/include\YYGML.h:70:44: note: expanded from macro 'YY_CHECK_ARG_RANGE'
#define YY_CHECK_ARG_RANGE( i, r )      (_yytmp_=(i), ((_yytmp_<(r)) ? _yytmp_ : (YYError("referencing argument index out of range %d", _yytmp_), 0)))
                                                ^
1 warning generated.
This is how I use this
Code:
obj_skey-Step at line 15:    image_angle = scp_sin_oscillate(-10,10,timer)
obj_picture-Step at line 15:    image_angle = scp_sin_oscillate(-8,8,timer)
obj_item1-Step at line 18:    image_angle = scp_sin_oscillate(-20,20,timer)
Any hint why GMS 2 give me the warning?
 

FrostyCat

Redemption Seeker
You probably wouldn't get that warning if you used a fixed number of arguments as you should have.
Code:
return((argument1-argument0)/2 * dsin(argument2) + (argument1+argument0)/2);
When you use argument[n] syntax, you are considered to be taking a variable number of arguments, even if you only use a fixed subset. Using the argument[n] syntax just to get compiler-end forgiveness for missed arguments is counterproductive. It doesn't make the problem go away, it delays the problem onto later development phases where fixing problems is harder and costs more.
 

funkygallo

Member
Oh thanks.
So, this is the correct syntax.

Oh damn, I had not seen that you had already written the correct syntax, but by reading the documentation I understood :)
Code:
///sin_oscillate(min,max,position)
return((argument1-argument0)/2 * dsin(argument2) + (argument1+argument0)/2);
 
Top