Jump to content
  • Advertisement
Sign in to follow this  
TheShadow344

Invalid use of void expression

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I received the error "invalid use of void expression" and it highlights this line...
AppState.Push(START_Input(), START_Render());
I'm thinking that it must have something to do with my Push() function...
struct GameState
{
  bool (*InputFunction)();
  void (*RenderFunction)();
  GameState *Next;
    
  GameState() { InputFunction = NULL; RenderFunction = NULL; Next = NULL; }
  ~GameState() { delete Next; }
};

void cStateFactory::Push(bool (*InputFunction)(), void (*RenderFunction)())
{
  // Check passed function
  if((InputFunction) != NULL && (RenderFunction != NULL))
  {
    // Allocate a new input state
    GameState *NewState = new GameState;
    
    // Push input function onto the stack
    NewState->Next = m_TopState;
    m_TopState = NewState;
    NewState->InputFunction = InputFunction;
    NewState->RenderFunction = RenderFunction;
  }
}

... or the fact that the START_Input() and START_Render() functions passed into Push() are virtual members of my cApplication class, which are overridden by the derived class cGameApp (all custom game-states are contained here). What does this error mean, and what is it caused by? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Probably your START_Input() and START_Render() functions return void and you're calling the functions in your AppState.Push() call, not passing their address. To pass their address you would use &cApplication::START_Input and &cApplication::START_Render. Of course, that still won't work because you can't assign member functions to normal function pointers. Consider using something like boost::function with boost::bind instead of using raw function pointers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!