Go to Post FIRST is a worthwhile program to be involved in as an Adult mentor. But for me, it does bring its share of personal conflict. ..... Cuz' you know when Jan 4/5 comes round' I'll be itchin to go gang busters again. I'll never learn - PMGRACER [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-01-2006, 14:21
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
"call of function without prototype"

When building a file in Mplab I get an error. It is "call of funtion without protoype." what does this mean and how do I fix it. I am very new to programming.
  #2   Spotlight this post!  
Unread 21-01-2006, 14:28
b_mallerd b_mallerd is offline
Programmer
FRC #1346 (Trobotics)
Team Role: Programmer
 
Join Date: Dec 2005
Rookie Year: 2005
Location: Vancouver
Posts: 35
b_mallerd is on a distinguished road
Send a message via MSN to b_mallerd
Re: "call of function without prototype"

It means you need to either define your function or else prototype it.

In a header file you need to type in something like this...


int funtion_name(int parameter_names);

and then in a file you need to actually define the function...

int function_name(int parameter_name)
{
your code goes here;
}


Make sure you have both parts and also make sure you have the header file included in whatever .c file that you are calling the function from.

incase you dont knoe calling = executing your function.

Hope this helps.
__________________
  #3   Spotlight this post!  
Unread 21-01-2006, 17:45
Melissa Crues Melissa Crues is offline
Registered User
FRC #0974
 
Join Date: Jan 2006
Location: Los Angeles
Posts: 2
Melissa Crues is an unknown quantity at this point
Re: "call of function without prototype"

You can also comment it out depending on what the function is. I ran into this problem on lines 184 and 246 on the users_routine on Kevin Watson's streamline code. When I found where those funtions were defined in the default code, it was in a file not encluded in the streamline one. It turned out that the default definition was replaced by some other code in the new version.

So, I just commented those functions out and it works fine!
  #4   Spotlight this post!  
Unread 21-01-2006, 18:43
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: "call of function without prototype"

IIRC it's just a warning. Provided the code gets through the linker fine, you can ignore it, but you should really fix it. You can either define it like b_mallerd said, or simply move the function up in the code, so that the compiler sees it before it tries to call it.
  #5   Spotlight this post!  
Unread 21-01-2006, 18:49
Andrew Blair's Avatar
Andrew Blair Andrew Blair is offline
SAE Formula is FIRST with Gasoline.
FRC #0306 (CRT)
Team Role: Alumni
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Corry
Posts: 1,193
Andrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond repute
Send a message via AIM to Andrew Blair Send a message via Yahoo to Andrew Blair
Re: "call of function without prototype"

Not to get too far off topic, but what is the purpose of a prototype in a header file? Why not just directly call it from a .c file?
__________________
Reading makes a full man, conference a ready man, and writing an exact man.
-Sir Francis Bacon

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
-Albert Einstein
  #6   Spotlight this post!  
Unread 21-01-2006, 18:53
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: "call of function without prototype"

Quote:
Originally Posted by Andrew Blair
Not to get too far off topic, but what is the purpose of a prototype in a header file? Why not just directly call it from a .c file?
In our code it doesn't matter to much, but in normal C/C++ you will often have your code divded up into modules. Each module might define say 10 functions. When you prototype something, the compiler can use it, even if it doesn't have the code to do it at that point. It just assumes that it will find the code for the function later on.

So if fileA.h has a prototype to "addThese(int,int,int)", and fileB and fileC both need to use it, they just have to include the header, rather then having three copies of the code for the function.
  #7   Spotlight this post!  
Unread 21-01-2006, 19:31
Andrew Blair's Avatar
Andrew Blair Andrew Blair is offline
SAE Formula is FIRST with Gasoline.
FRC #0306 (CRT)
Team Role: Alumni
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Corry
Posts: 1,193
Andrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond reputeAndrew Blair has a reputation beyond repute
Send a message via AIM to Andrew Blair Send a message via Yahoo to Andrew Blair
Re: "call of function without prototype"

I guess my question is, why do you need the intermediary .h file?

If fileA.c has function "drive(int,int)", and both fileB.c and fileC.c need that function, why not call the function from fileA.c, instead of the prototype from fileA.h?

Maybe I missed your original idea. Does the .h file act as a condenser, #including prototypes from several files, so that instead of calling fileA,B,C.c, you simply call Condenser.h that contains all these prototypes?

Or does it simply act as a place holder, so that you can execute higher level code, while the function is still not actually written? So it calls the function prototype, so it will compile, but so that when you execute it, it does nothing? Thanks!
__________________
Reading makes a full man, conference a ready man, and writing an exact man.
-Sir Francis Bacon

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
-Albert Einstein
  #8   Spotlight this post!  
Unread 21-01-2006, 19:59
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: "call of function without prototype"

Yes, the .h files condense stuff. In another way, they making changing things easy. For example, last two years I used a file called "defines.h". In it I had stuff like this:

Code:
#define DRIVE_LEFT pwm01
#define DRIVE_RIGHT pwm02
This provided two advantages: 1) I could easily change the mappings of our pwm's around, and 2) When it came time to wire the robot, I printed off this file, and it was easy to match PWM's to their function.

The first reason was the main reason to change something. If you need to add another parameter to a function, and its in a .h file, then you change it there, and any code that used the old version would be highlighted.. with it defined in multiple .c files, you could get some strange errors.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Analog-to-Digital Converter Code Kevin Watson Programming 29 17-02-2008 13:07
Loop time for OperatorControl function? Debug blows... Chris_Elston Programming 10 13-02-2006 14:42
TTL port to a serial port on a demo board ImmortalAres Programming 16 09-07-2005 23:44
RoboEmu2(code simulator)--now with C! rbayer Programming 23 17-02-2005 09:17
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 01:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi