About Store Forum Documentation Contact
Donations:
206$/mo



Post Reply 
State does not recognize functions
Author Message
AndrewBGS Offline
Member

Post: #1
State does not recognize functions
Hello, I can't figure out what I'm doing here, as this is state is a copy-paste from a working one with little modifications:

This looks all right to me, but when I try to build, I get undeclared identifier for all the functions of the state (UpdateReg, DrawReg, InitReg, ShutReg).
If you can spot what I'm doing wrong, I'd appreciate it very much.

Code:
State StateRegister (UpdateReg, DrawReg, InitReg,  ShutReg);
/********************************************************************************​**/
Bool InitReg()
{
   GRegister.create();
   return true;
}

void ShutReg()
{
}

Bool UpdateReg()
{
   if(Kb.bp(KB_ESC)) {StateMenu.set();}
   Gui.update();
   soundtrack.update(HEROIC);
   return true;
}

void DrawReg()
{
   D.clear(BLACK);
   Gui.draw();
}
(This post was last modified: 07-24-2014 08:31 AM by AndrewBGS.)
07-24-2014 08:30 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: State does not recognize functions
State StateRegister (UpdateReg, DrawReg, InitReg, ShutReg);

Should be at the bottom not top smile
07-24-2014 08:34 AM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #3
RE: State does not recognize functions
That would be a first. All states I wrote before have the declaration at the top (about 5 or 6) and they all work fine. But I'll try as soon as I get home, thanks.
07-24-2014 09:00 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: State does not recognize functions
Hi,

The codes are OK, you don't need to place them below because Code Editor does the necessary rearrangements for you.
It compiled for me OK.
If it still doesn't work for you, try "Rebuild" option, if that still fails you can attach entire project here.
07-24-2014 09:11 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #5
RE: State does not recognize functions
if you were using visual studio none of your states would allow a successful compilation because the function either has to be forward declared or State registering has to be done at the end of file.

It's not always clear as to when someone is using code editor or not. wink
(This post was last modified: 07-24-2014 09:14 AM by Zervox.)
07-24-2014 09:13 AM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #6
RE: State does not recognize functions
I was using the code editor, yes. And I tried clean all and rebuild, it still failed.
I will try re-creating the file and see if that works (maybe it didn't like I created it with duplicate from another one..?)

If the problem persists I'll attach a small project with the issue.
07-24-2014 09:32 AM
Find all posts by this user Quote this message in a reply
Post Reply