why warning

M

Michael Sgier

Hi
I get:
.../src/cit_x.cpp: In function 'int FadeIN()':
.../src/cit_x.cpp:476: warning: control reaches end of non-void function

Why this warning in the function below?
Thanks Michael


int FadeIN()
{

int start = SDL_GetTicks();

// Only call this when 100 ms have elapsed
while (AlphaV > 0.0f)
{
if( SDL_GetTicks() - start > 100 )
{
// Reassign the time elapsed
start = SDL_GetTicks();

// Decrease the alpha value by this much
AlphaV -= 0.005;
return AlphaV;
}
}
}
 
L

Lionel B

Hi
I get:
../src/cit_x.cpp: In function 'int FadeIN()': ../src/cit_x.cpp:476:
warning: control reaches end of non-void function

Why this warning in the function below? Thanks Michael


int FadeIN()
{

int start = SDL_GetTicks();

// Only call this when 100 ms have elapsed
while (AlphaV > 0.0f)
{
if( SDL_GetTicks() - start > 100 )
{
// Reassign the time elapsed
start = SDL_GetTicks();

// Decrease the alpha value by this much AlphaV -= 0.005;
return AlphaV;
}
}
}

Your function has to return an int. What happens if the while loop
terminates without returning (i.e. the `if' clase is never entered)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top