Go to Post This is the best experience you will ever get. - Arefin Bari [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 02-02-2005, 21:12
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Question strange warning when build program

I have created a pair of files: user_common.c and user_common.h and added them to the workspace. user_common.h includes user_common.c . Inside user_common.c are several functions I use during an interrupt to read a sensor. all functions in user_common.c are stated in user_common.h with the return type and any parameters in () then followed by a semicolon. In each file where any function from user_common.c is used, user_common.h is included. When I make or build everything, the build succeeds but for each function i used that came from user_common.c, I receive the following error:
" file path : line number : Warning [2058] call of function without prototype ". I have no idea what it means, but the functions don't work. Could this error be a side effect of the problem that is preventing the functions from working correctly? Any help would be appreciated.
  #2   Spotlight this post!  
Unread 02-02-2005, 21:45
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,825
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: strange warning when build program

Post the two files for us to check out.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 02-02-2005, 21:59
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: strange warning when build program

Quote:
Originally Posted by PVC Pirates
" file path : line number : Warning [2058] call of function without prototype ".
My guess is you have something as follows...

Code:
#include "user_common.h"
main
{
  foo();
}

void foo(void)
{
 // Do something
}
Try adding a function prototype for foo() to your user_common.h file.
Code:
void foo(void);
From this article
Quote:
A declaration or prototype is a way of telling the compiler the data types of the any return value and of any parameters, so it can perform error checking.
Essentially your compiler is complaining that you're using a function that it doesn't know about.
  #4   Spotlight this post!  
Unread 02-02-2005, 22:04
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: strange warning when build program

Something to also consider...

If you are using the functions in files other than user_common.c, you will probably have to use prepend the prototype with extern and include user_common.h in those files
Code:
extern foo(void);
This tells the compiler that the file will be using a function that is defined externally to the file being compiled.
  #5   Spotlight this post!  
Unread 02-02-2005, 22:26
steven114 steven114 is offline
Programming Wizard and Team Captain
AKA: Steven Schlansker
FRC #0114 (Eaglestrike)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Los Altos, CA
Posts: 335
steven114 is a jewel in the roughsteven114 is a jewel in the roughsteven114 is a jewel in the rough
Send a message via AIM to steven114
Re: strange warning when build program

Quote:
Originally Posted by PVC Pirates
user_common.h includes user_common.c .
I hope you meant that the other way around. Never, ever, do a #include "myfile.c" unless you want a big headache
__________________
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!
  #6   Spotlight this post!  
Unread 03-02-2005, 08:34
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Thank you all. I will take another look at the code and try your suggestions and see if they work. I'll let you know what happens.
  #7   Spotlight this post!  
Unread 03-02-2005, 15:38
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Adding the "void" in the parentheses prevented all but one of the warnings. Before the addition, every time a function from user_common.c was called, I would get the warning. Now i only get the warning when I call the initialization function.

I am going to post the code on the assumption that I can trust the users of this site to not steal my ideas unless they have already thought of it on their own. Please do not make this assumption incorrect.

The user_common.h is as follows:

#ifndef __user_common_h_
#define __user_common_h_
/************************************************** *************/
extern unsigned char rc_dig_in03last;
extern long tmpcount;
extern int inturrupt;
/************************************************** *************/
void init_HallEffect(void);
void updateSpeed(int pwmL, int pwmR);
void setLastPWM(void);
void handleHallEffect(void);
long getCountLeft(void);
long getCountRight(void);
/************************************************** *************/
#endif

I tried using extern before each function but it had no effect.
Here is user_common.c:

#include "user_common.h"
#include "ifi_aliases.h"
#include "ifi_default.h"

int prevL, prevR, currL, currR; /*used when determining
which direction to count when changing the count in update speed,
init_hallEffect and setLastPWM */

unsigned char lastPWMLeft, lastPWMRight, lastPORTB; /*used to find
change in sensors, and keep track of direction*/

long countLeft, countRight; /*used to keep track of increments
sensed by the hallEffect sensors*/

unsigned char rc_dig_in03last;
long tmpcount;
int inturrupt = 0;
/************************************************** *************/
void init_HallEffect(void)
{
/*init wheel counts to 0 each*/
countLeft = 0;
countRight= 0;
/*first initialization of PORTB*/
lastPORTB = PORTB;
/*init for prev left and right pwm values*/
prevL = 129;
prevR = 129;
digital_io_03 = 1;
digital_io_04 = 1;
INTCON2bits.RBPU = 0;
tmpcount = 5;
rc_dig_in03 = 0;
rc_dig_in03last = rc_dig_in03;

/*inti inturrupt flag bit enabled*/
INTCONbits.RBIE = 1;
}
/************************************************** *************/

/************************************************** *************/
/*here comes the code to set lastPWMLeft/Right.*/
void updateSpeed(int pwmL, int pwmR)
{
currL = pwmL;
currR = pwmR;
}
/************************************************** *************/

/************************************************** *************/
void setLastPWM(void)
{
if (currL != 128)
{
lastPWMLeft = currL;
prevL = currL;
}
else
{
if (prevL > 128)
{
lastPWMLeft = 200;
}
else if (prevL < 128)
{
lastPWMLeft = 50;
}
}
if (currR != 128)
{
lastPWMRight = currR;
prevR = currR;
}
else
{
if (prevR > 128)
{
lastPWMRight = 200;
}
else if (prevR < 128)
{
lastPWMRight = 50;
}
}
}
/************************************************** *************/

/************************************************** *************/
/*inturrupt code*/
void handleHallEffect(void)
{/*left sensor = rc_dig_in03, right = rc_dig_in04: left = bit 4,
right = bit 5*/
unsigned char thisPortB, change;
thisPortB = PORTB & 0b00011000;
change = thisPortB ^ lastPORTB;
switch(change)
{
case 0: break;
case 48:
{
if (lastPWMLeft > 128)
{
countLeft ++;
}
else if (lastPWMLeft < 128)
{
countLeft --;
}
if (lastPWMRight > 128)
{
countRight ++;
}
else if (lastPWMRight < 128)
{
countRight --;
}
break;
}
case 16:
{
if (lastPWMLeft > 128)
{
countLeft ++;
}
else if (lastPWMLeft < 128)
{
countLeft --;
}
break;
}
case 32:
{
if (lastPWMRight > 128)
{
countRight ++;
}
else if (lastPWMRight < 128)
{
countRight --;
}
break;
}
}

}
/************************************************** *************/

/************************************************** *************/
long getCountLeft(void)
{
return countLeft;
}
/************************************************** *************/

/************************************************** *************/
long getCountRight(void)
{
return countRight;
}
/************************************************** *************/

I apologize if it is difficult to read. Code does not paste well into these windows.

Here is where the functions are used:

In user_routines.c:
in User_Initialization:
{
...
init_HallEffect();
}

in Default_Routine
{
inside the #if and #else statements where the pwm values are set...
right at the end of each block: updateSpeed();
after that for testing purposes: I put a printf displaying the count values recieved from getCountLeft() and getCountRight();
}


in user_routines_fast.c
in InturruptHandlerLow()
{
inside the section that checks INTCONbits.RBIF and INTCONbits.RBIE...
setLastPWM();
handleHallEffect();
}


Even with the void in the parentheses, I still get the warning about init_HallEffect(); at the location where it is called.
Besides that, the display is always zero for both sensor counters. Does anyone see a problem that I missed? user_common.h and user_common.c are direct copy and paste. The locations of the calls are description mostly. If anyone has any questions, feel free to ask. I will try to answer them.

Thank you all.

P.S. I am sorry about the length of this post.

Last edited by PVC Pirates : 03-02-2005 at 15:41. Reason: added apology
  #8   Spotlight this post!  
Unread 03-02-2005, 16:41
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: strange warning when build program

Quote:
Originally Posted by PVC Pirates
I apologize if it is difficult to read. Code does not paste well into these windows.
Try using a code block (replace the <'s in the text below with a [)
Code:
<code]code goes here</code]
Is it safe to say that you're including user_common.h in both user_routines.c and user_routines.h?

Quote:
I put a printf displaying the count values recieved from getCountLeft() and getCountRight()
What if you put a print in those functions? Are you sure they're getting called? Did you typecast your variables in your printf?
  #9   Spotlight this post!  
Unread 03-02-2005, 17:38
Mike AA's Avatar
Mike AA Mike AA is offline
Programmer and Mentor
AKA: Mike Aalderink
FRC #3458 (Code Blue)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Holland, Mi
Posts: 698
Mike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to behold
Send a message via MSN to Mike AA
Re: strange warning when build program

OK, quick probably stupid question once I get a response. How does one upload their program to the robot? Do we use the IFI Loader the same way as for loading the new firmware or whatever it was? I have code and it debugs ok so I would like to load to the robot. I haven't used this program before (I'm using the Mplad IDE), and last year someone else did programming on the other team I was on. I did the programming previously for 3/4 years with basic so I understand the most part, just don't know how to upload!


-Mike
  #10   Spotlight this post!  
Unread 03-02-2005, 17:43
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: strange warning when build program

Quote:
Originally Posted by Mike AA
Do we use the IFI Loader the same way as for loading the new firmware or whatever it was?
Yes, use the IFI loader with the hex file that was created when you compiled your code.
  #11   Spotlight this post!  
Unread 03-02-2005, 17:51
Mike AA's Avatar
Mike AA Mike AA is offline
Programmer and Mentor
AKA: Mike Aalderink
FRC #3458 (Code Blue)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Holland, Mi
Posts: 698
Mike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to beholdMike AA is a splendid one to behold
Send a message via MSN to Mike AA
Re: strange warning when build program

Quote:
Originally Posted by Dave Scheck
Yes, use the IFI loader with the hex file that was created when you compiled your code.

Thank you, I thought that was it but it seemed odd. Thanks alot. now we can complete our robot.
  #12   Spotlight this post!  
Unread 03-02-2005, 23:19
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Quote:
Originally Posted by Dave Scheck
Is it safe to say that you're including user_common.h in both user_routines.c and user_routines.h?

What if you put a print in those functions? Are you sure they're getting called? Did you typecast your variables in your printf?
I included user_common.h in user_routines.c, but I didn't know I needed to or should include it in user_routines.h . I did not put a printf in the get functions and I don't know for sure if they are being called. I did not consciously typecast the printf. What must be done to the printf? I will try the added include and the extra printf. Please tell me more about the typecasting of printf. Also, thanks for telling me about the code block.
  #13   Spotlight this post!  
Unread 04-02-2005, 10:49
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: strange warning when build program

Quote:
Originally Posted by PVC Pirates
I included user_common.h in user_routines.c, but I didn't know I needed to or should include it in user_routines.h.
That's because I mistyped...I meant to say user_routines_fast.c...you shouldn't include user_common.h in user_routines.h...

Quote:
Please tell me more about the typecasting of printf.
Eugene Brooks had a good explanation in this thread about casting variables and printf.
Quote:
Originally Posted by eugenebrooks
The default way in which arguments are pushed, for routines
that do not have their arguments declared, is char.
He gives an example of how to perform the casting right above that explaination
Quote:
Originally Posted by eugenebrooks
Explicitly cast the integer arguments being provided to printf
to the desired type. If x is an int, y is a int, and z is a long,
use: printf("%d %d %lx\n", (int)x, (int)y, (long)z);
  #14   Spotlight this post!  
Unread 04-02-2005, 14:48
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Ok. Thanks. If that is the case, then I did include user_common.h in user_routines.c and user_routines_fast.c . I also was not typecasting the variables in the printf statement. I will try that.
__________________
In practice, the difference between theory and practice, is greater than it is in theory.
  #15   Spotlight this post!  
Unread 04-02-2005, 19:49
PVC Pirates PVC Pirates is offline
Programmer
#1058 (PVC Pirates)
Team Role: Programmer
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Londonderry, NH
Posts: 7
PVC Pirates is an unknown quantity at this point
Send a message via AIM to PVC Pirates Send a message via MSN to PVC Pirates
Re: strange warning when build program

Thanks to all who contributed suggestions. The problem has been resolved.

Thanks again
PVC Pirates
__________________
In practice, the difference between theory and practice, is greater than it is in theory.
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
Where do you actually build your robot and who does the building??? Elgin Clock General Forum 47 14-11-2006 17:50
OCCRA Teams - where do you build? Phil 33 OCCRA 7 28-10-2004 21:41
how to add steps in the provided encoder program for the edu Zaramel2002 Programming 3 11-02-2004 08:35
warning about taxes robot180 Chit-Chat 3 16-10-2003 17:36
Ahh! Program trick confusing! archiver 2001 9 24-06-2002 02:26


All times are GMT -5. The time now is 10:51.

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