Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » I have an error with my code and have no idea how to fix it

Credits go to Peter Hull for helping out!
This thread is locked; no one can reply to it. rss feed Print
I have an error with my code and have no idea how to fix it
Desmond Taylor
Member #11,943
May 2010
avatar

I am trying to make a basic game engine that all my games can run off. So basically just a skeleton of sorts.

Anyway, the issue I am having is this...

||=== Build: Windows - Debug in game-engine (compiler: GNU GCC Compiler) ===|
..\include\system\input.h|22|error: expected ')' before '*' token|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Now I cannot find the issue anywhere and have spent ages looking for it. Thought I would ask the professionals on this matter to see what I am missing. They do say that a second pair of eyes can spot issues easier.

I have opened the source code to the public to get the issue fixed. You can get all the source code from my BitBucket repository.

Any help on this matter will be highly appreciated. Thank you :)

Arthur Kalliokoski
Second in Command
February 2005
avatar

I'm ignorant of C++, but I think it wants line 22 of system/input.h to be

        Input( (Events *) events );

instead of

        Input(Events* events );

just like you'd have (int *) myintptr

HTH

They all watch too much MSNBC... they get ideas.

Peter Hull
Member #1,136
March 2001

My guess is that it doesn't know what Events is. You can either make sure that events.h is always #included before input.h or just put a forward declaration

class Events;

near the top of input.h

Desmond Taylor
Member #11,943
May 2010
avatar

My guess is that it doesn't know what Events is. You can either make sure that events.h is always #included before input.h or just put a forward declaration

class Events;
near the top of input.h

Thank you so much. I knew it would be something simple that I was missing. Like its said. Fresh eyes make such a difference.

Thank you again.

anto80
Member #3,230
February 2003
avatar

{"name":"my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/6\/e674cbf470d938c51ce4821abc79943b.jpg","w":735,"h":1116,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/6\/e674cbf470d938c51ce4821abc79943b"}my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Peter Hull
Member #1,136
March 2001

When looking at my own code I have one of two reactions:

Quote:

I can't believe I wrote that!

or

Quote:

I can't believe I wrote that!

Unfortunately it's mostly the latter.

Desmond Taylor
Member #11,943
May 2010
avatar

I laughed so hard when I read both of those new replies ;D Yes, it was a little bit of a silly mistake. Can't believe that I didn't realize the mistake I made. I've never had that error before due to not forgetting to put the one line of code needed in the header until yesterday.

Thanks again though, Since I could move on from that I've now wrote the sound class ready for my game engine :)

The hardest part of it for me should be adding Multiplayer support since I have only worked with Winsock and I really want it to be cross-platform. Wish me luck on that one :-/

amarillion
Member #940
January 2001
avatar

It's not a silly mistake. Or maybe: all programming mistakes are silly mistakes.

Imagine a Shakespeare play. There are 10000 words in it. But the playwright forgot a semicolon somewhere in the middle, and now the audience completely failed to parse it and misunderstood the plot. It was supposed to be a comedy, but due to that one missing semicolon, everybody listening interpreted it as a murder mystery. That's just what programming is like.

anto80
Member #3,230
February 2003
avatar

I agree: that's not a silly mistake!

In this part of the forum, we can be off-topic! ;)

This reminds me
http://www.mit.edu/afs.new/net/user/tytso/archive/hackers.test

Quote:

0477 Ever spend ten minutes trying to find a single-character error?

0478 ... More than an hour?

0479 ... More than a day?

0480 ... More than a week?

0481 ... Did the first person you show it to find it immediately?

___________
Currently working on his action/puzzle game CIPHER PUSHER : Blocks/Vortexes/Seafood! Facebook - Twitter - webpage

Peter Hull
Member #1,136
March 2001

It's not a silly mistake.

Agreed. It amazes me that GCC produces such an unhelpful message in this situation.

[edit] Some original research!

class Input {
public:
  Input(Events* events);
private:

};

GCC

des.cc:3:15: error: expected ‘)’ before ‘*’ token
   Input(Events* events);
               ^

CLANG

des.cc:3:9: error: unknown type name 'Events'
  Input(Events* events);
        ^

MSVC

des.cc(3): error C2061: syntax error: identifier 'Events'

Clang wins!

For GCC if you put ')' where it says, it parses

Input(Events);

as if it were

Input Events;

i.e. a definition of a variable called Events of type Input.
::)

bamccaig
Member #7,536
July 2006
avatar

The hardest part of it for me should be adding Multiplayer support since I have only worked with Winsock and I really want it to be cross-platform. Wish me luck on that one :-/

Don't worry. Microsoft based Winsock off of Berkeley Sockets the same as every other UNIX OS. Microsoft's socket library is more limited, and you need to set up some pre-processor platform specifics at first, but after that most of it is shared code. And you're already used to Winsock so you won't miss any of the features in UNIX that you don't know about. ;)

i.e. a definition of a variable called Events of type Input.
::)

What does it do with the trailing "events);"?!

Desmond Taylor
Member #11,943
May 2010
avatar

bamccaig said:

Don't worry. Microsoft based Winsock off of Berkeley Sockets the same as every other UNIX OS. Microsoft's socket library is more limited, and you need to set up some pre-processor platform specifics at first, but after that most of it is shared code. And you're already used to Winsock so you won't miss any of the features in UNIX that you don't know about. ;)

I'm glad to hear that as I think that is the part I shall be working on tomorrow evening. For now I am working on some basic physics that most games would need.

Just want to release a better game than my last Picture Puzzle game back in January 2011 ;D Shamefully written with SDL.

Random Screenshot

{"name":"t8A8Gti.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/9\/d97afbaca575eab6c6b8a4d9a02a4169.png","w":348,"h":367,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/9\/d97afbaca575eab6c6b8a4d9a02a4169"}t8A8Gti.png

Bob Keane
Member #7,342
June 2006

The hardest part of it for me should be adding Multiplayer support since I have only worked with Winsock and I really want it to be cross-platform. Wish me luck on that one

Have you looked into Boost::Asio?It is cross platform and c++11 compliant.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Desmond Taylor
Member #11,943
May 2010
avatar

Quote:

Have you looked into Boost::Asio? [www.boost.org]It is cross platform and c++11 compliant.

I haven't! However that does look like it could do the trick. Thank you for that, It's now on my TODO/Look into list.

Bob Keane
Member #7,342
June 2006

If you find great instructions on installing it and using it with VS, Code::Blocks or Netbeans, share the link.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Desmond Taylor
Member #11,943
May 2010
avatar

Sure will. Haven't found one myself yet so I'm just going to make a test project and swing it. I use Code::Blocks so if I manage to get it working I can share the steps taken. Someone might be able to make it easier from that.

Bob Keane
Member #7,342
June 2006

Did you get the Windows SDK to work with Code::Blocks?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Desmond Taylor
Member #11,943
May 2010
avatar

I have not. I keep getting errors but I wont give up as it sounds too good to just throw away.

Bob Keane
Member #7,342
June 2006

These instructions suggest it can be done, but you have to use a nightly build. The download page for the build is Jen's Fedora Page, which suggest it is only for Linux. I tried the instructions but my project can't find the Ws2_32.lib. There is a slight chance the global settings are overriding the debug settings, or vice versa. I tried it with the regular download, not the nightly build btw.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Desmond Taylor
Member #11,943
May 2010
avatar

why cant it find ws2_32? its winsock so it should work. But I shall look into that maybe tomorrow. As of now I've promised some friends to play some Minecraft with them. ;)

Bob Keane
Member #7,342
June 2006

It looks like a common problem per Google. One solution was the global settings were overriding the debug settings. I'll test it Saturday. Figuring out how to get around my anti virus software is going to be fun. My laptop may be iffy. I updated flashplayer at least twice in the last two weeks and I got an update notice again tonight.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Gideon Weems
Member #3,925
October 2003

I just stopped by to say this thread title more or less summarizes my life.

Desmond Taylor
Member #11,943
May 2010
avatar

I still can't get Boost:Asio to work. Going to look up on it a lot more as it sounds too good to just give up on. Even though my game engine is not being worked on due to this XD

I blame you Bob Keane ;)

Bob Keane
Member #7,342
June 2006

I still can't get Boost:Asio to work.

Are you following these instructions? It says there is an installer but I can't get it to work.

I blame you Bob Keane

If it makes you feel better, I had a horrible night at my night job. One huge problem, and lots of little ones. I think I'll boot up a computer game and go on a rampage. They'll curse my name on the Sword Coast. No evil grin emoticon?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Go to: