How to call void functions (like shoot)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jhend60
Posts: 44
Joined: Mon Oct 27, 2008 10:11 am
Location: behind you
Contact:

How to call void functions (like shoot)

Post by jhend60 »

Hi all
I am wondering how to get this thing working. I have finished implementing a shoot function(void shoot()) but , when I try to use it in my code by just using 'shoot()' I get this error:

main.cpp(248) : error C2365: 'shoot' : redefinition; previous definition was 'data variable'
main.cpp(24) : see declaration of 'shoot'

line 248 is where the opening left bracket of shoot is, line 24 is where I call shoot(). What am I doing wrong? I have examined the demo and see nothing different between mine and theirs, except theirs works.
Thanks.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The error message tells you that the declaration of 'shoot' at line 24 is a 'data variable'. This code generates the same error:

Code: Select all

int shoot;

void shoot() { }
I think we'll need to see your code to figure out exactly how you've managed to confuse the compiler. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

You need to define, then declare and then call your function, example.

Code: Select all

//create instance of shoot
void shoot();

//define the shoot funtion
void shoot()
       {
       //all code to shoot
       }

       //call function
      shoot();

//end
try that, thats where I think you went wrong in creating an instance, defining, and calling.
-System error
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You don't actually need all that code, for example the 'instance' (bad word use there, instance is normally to do with objects that you've created, better word would be declaration), that's not necessary in your snippet of code as the function is defined before the the call anyway. )
Image Image Image
Post Reply