Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,514 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,851 people online right now. Registration is fast and FREE... Join Now!




Function calling (C)

 
Reply to this topicStart new topic

Function calling (C)

eLliDKraM
post 19 Nov, 2005 - 04:30 PM
Post #1


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


Haven't needed to call functions yet, but I'm getting an error and am not sure how to solve this.

CODE

void si();
void us();
void main()
{
    scanf("%d", unit);
    if(unit=1) si();  // calls the corresponding function via user input
    else us();
}
void si()  [B]line 24; line of error[/B]
{  
//more content..
}


Error:
QUOTE

(Line 24): warning #2027: Missing prototype for 'si'.

and

POLINK: error: Unresolved external symbol '_us'.
POLINK: fatal error: 1 unresolved external(s).


Not sure exactly what to do, and am confused why that code isn't allowing me to call the function void si() {. If you can help, much obliged.
User is offlineProfile CardPM

Go to the top of the page


Amadeus
post 19 Nov, 2005 - 06:45 PM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 31 times

Dream Kudos: 25
My Contributions


What compiler are you running? I just compiled the following us gcc from the command line
CODE

void si();
void us();
int main()
{
int unit;
scanf("%d", unit);
if(unit=1)
{
  si();  // calls the corresponding function via user input
}
else
{
  us();
}
}

void si()
{  
//more content..
}

void us()
{  
//more content..
}

no errors.
User is offlineProfile CardPM

Go to the top of the page

eLliDKraM
post 19 Nov, 2005 - 07:39 PM
Post #3


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


PellesC
http://www.smorgasbordet.com/pellesc/

also, It said it was just a warning so I figured it would still build, but for some reason it's being extraordinarily anal about this function naming thing.

This post has been edited by eLliDKraM: 19 Nov, 2005 - 07:41 PM
User is offlineProfile CardPM

Go to the top of the page

eLliDKraM
post 20 Nov, 2005 - 08:46 AM
Post #4


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


What compiler are you running? This PellesC is such a hater when it comes to building, I'm thinking it's time to get a new one.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 20 Nov, 2005 - 09:40 AM
Post #5


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 31 times

Dream Kudos: 25
My Contributions


I run a bunch of them, everything from M$ Visual Studio to Dev C++, and different ones on different operating systems. The validation I did with your code was with GNU gcc using Cygwin as the interface, but I also ran it in VS, compiled fine. Both those were on windows machines, so I also ran it on my linux box...again, no compile errors.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 12:52AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month