Here is my code snippet: [Full Code]
void Draw_Square (HDC DeviceContext, int Cnt, ...)
{
int Cnt_1, Cnt_2, Cnt_3, Cnt_4;
for (Cnt_1 = 0; Cnt_1 < 4; Cnt_1++)
{
for (Cnt_2 = 0; Cnt_2 < 6; Cnt_2++)
{
va_list Ap;
va_start (Ap, (Cnt*4));
for (Cnt_3 = 0; Cnt_3 < Cnt; Cnt++)
Draw_Line (DeviceContext, (Cnt_1*6+Cnt_2), va_arg (Ap, short), va_arg (Ap, short), va_arg (Ap, int), va_arg (Ap, COLORREF));
va_end (Ap);
}
Sleep (User_Def_Delay);
}
}
GCC/mingw32 reported:
| |In function 'Draw_Square': |
|393|warning: second parameter of 'va_start' not last named argument [enabled by default] |
|395|warning: 'short int' is promoted to 'int' when passed through '...' [enabled by default]|
|395|note: (so you should pass 'int' not 'short int' to 'va_arg') |
|395|note: if this code is reached, the program will abort |
|395|warning: 'short int' is promoted to 'int' when passed through '...' [enabled by default]|
|395|note: if this code is reached, the program will abort |
Why? wrong type?
Thanks.
Added:
I've modified my code, but it is still failed.
void Draw_Square (HDC DeviceContext, int Cnt, ...)
{
va_list Ap;
va_start (Ap, Cnt);
int Cnt_1, Cnt_2, Cnt_3;
for (Cnt_1 = 0; Cnt_1 < 4; Cnt_1++)
{
for (Cnt_2 = 0; Cnt_2 < 6; Cnt_2++)
{
for (Cnt_3 = 0; Cnt_3 < Cnt; Cnt++)
Draw_Line (DeviceContext, (Cnt_1*6+Cnt_2), (short)va_arg (Ap, int), (short)va_arg (Ap, int), va_arg (Ap, int), va_arg (Ap, COLORREF));
}
Sleep (User_Def_Delay);
}
va_end (Ap);
}
and get no warnings