|
Page 1 of 1
|
[ 14 posts ] |
|
Problem with inline functions in 1.93
| Author |
Message |
|
johncdelacy
Rookie
Joined: Mon Dec 15, 2008 3:30 pm Posts: 7
|
 Problem with inline functions in 1.93
With 1.93 this compiles: This doesn't: I get this error: **Error**:Empty 'non-void' function not allowed. 'return' statement is required with a red X on the close brace. John DeLacy Benson Robotics Club
|
| Wed Sep 16, 2009 1:57 am |
|
 |
|
l0jec
Expert
Joined: Mon Oct 27, 2008 9:59 pm Posts: 137
|
 Re: Problem with inline functions in 1.93
Yes, I posted the same bug in 1.91 here: http://www.robotc.net/forums/viewtopic.php?f=33&t=1838. Depending on what your inline function is doing, you may be able to write an extra copy of it with another name for each task you are calling it from. This is a poor approach in my mind, but it may hold us over until the inline function is properly fixed?
|
| Wed Sep 16, 2009 7:58 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: Problem with inline functions in 1.93
well, this indeed is a VERY POOR approach  inline worked well with all my code from 1.10 up to 1.45, see this:  |  |  |  | Code: /////////////////////////////////////////////////////////////////////// // math.h // // mathematische Konstanten und Funktionen // // Version 0.1.1 // ///////////////////////////////////////////////////////////////////////
#define _MATH_H
//=================================================================== // mathematische Konstanten und Funktionen //===================================================================
// Eulersche Zahl E: const float E=2.718281828450945235360287471352662497757247093699959574966967627724076630353547594571;
//********************************************
inline int min(int a, int b) { return(a<b ? a:b); }
inline float min(float a, float b) { return (a<b ? a:b); }
//********************************************
inline int max(int a, int b) { return (a>b ? a:b); }
inline float max(float a, float b) { return (a>b ? a : b); }
//********************************************
inline int round(float f) { if (f>=0) {return (int)(f + 0.5);} else {return (int)(f - 0.5);} }
//********************************************
// ArcusTangens mit Sonderfaellen; Angabe in radians! // x=Ankathete y=Gegenkathete Tangens=y/x
inline float atan2(float x, float y) { float phi; //phi=Bogenmass;
if (x>0) {phi=atan(y/x);} else if ((x<0)&&(y>=0)) {phi=PI+atan(y/x);} else if ((x<0)&&(y<0)) {phi=-PI+atan(y/x);} else if ((x==0)&&(y>0)) {phi=PI/2;} else if ((x==0)&&(y<0)) {phi=-PI/2;} else if ((x==0)&&(y==0)) {phi=0;}
return phi; }
// ArcusTangens; dto., aber mit Angabe in Grad!
inline float atan2Degrees(float x, float y) { return(radiansToDegrees(atan2(x,y))); }
//********************************************
// Tangens Hyperbolicus
inline float tanh(float x) { float e2x; e2x=exp(2*x); return((e2x-1)/(e2x+1)); }
//********************************************
// for int values inline bool IsInRange(int Wert, int Basis, int Toleranz) { return((Wert>=Basis-Toleranz) && (Wert<=Basis+Toleranz)); }
// for float values inline bool IsInRange(float Wert, float Basis, float Toleranz) { return((Wert>=Basis-Toleranz) && (Wert<=Basis+Toleranz)); }
//=================================================================== //===================================================================
|  |  |  |  |
That it currently doesn't compile correctly must be a new issue. And you can't expect programmers to write a copy for all functions for all tasks, do you?? 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Wed Sep 16, 2009 8:19 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Problem with inline functions in 1.93
The bug is on the issue list and has been assigned to be fixed.
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Sep 16, 2009 8:26 am |
|
 |
|
kareka
Rookie
Joined: Sun Jul 18, 2010 2:14 pm Posts: 4
|
 Re: Problem with inline functions in 1.93
Here we are at 2.02 and the same problem still remains !!!
|
| Sun Jul 18, 2010 2:29 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Problem with inline functions in 1.93
What problem are you seeing?
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Jul 18, 2010 2:50 pm |
|
 |
|
Gary Samad
Expert
Joined: Mon Mar 15, 2010 4:24 pm Posts: 124
|
 Re: Problem with inline functions in 1.93
I'm not sure if this is the problem, but this is not exactly the correct syntax in C:
int inline min(int value1, int value2)
The correct syntax is:
inline int min(int value1, int value2)
Does this fix it?
cu, Gary
|
| Sun Jul 18, 2010 5:10 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Problem with inline functions in 1.93
As of 2.16.1, inline functions are turned into normal functions. inline functions are no longer supported.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Jul 18, 2010 5:18 pm |
|
 |
|
kareka
Rookie
Joined: Sun Jul 18, 2010 2:14 pm Posts: 4
|
 Re: Problem with inline functions in 1.93
What I'm saying is that this still doesn't work:
------------------------------------------- inline int GetDistance() { return(5); }
task main() { int Distance; Distance = GetDistance(); } --------------------------------------------
|
| Sun Jul 18, 2010 5:56 pm |
|
 |
|
kareka
Rookie
Joined: Sun Jul 18, 2010 2:14 pm Posts: 4
|
 Re: Problem with inline functions in 1.93
mightor what is the workaround for not having inline functions ?
|
| Sun Jul 18, 2010 5:59 pm |
|
 |
|
Gary Samad
Expert
Joined: Mon Mar 15, 2010 4:24 pm Posts: 124
|
 Re: Problem with inline functions in 1.93
What about just removing the "inline" keyword? There's normally no need for an inline function in C, it's just an optimization suggestion, but I did notice that RobotC required the use of inline functions if the same function was called from two different tasks - I'm not sure why. Sounds like Xander is saying inline functions are no longer needed or supported, so maybe try just removing the "inline" keyword? cu, Gary
|
| Sun Jul 18, 2010 6:28 pm |
|
 |
|
kareka
Rookie
Joined: Sun Jul 18, 2010 2:14 pm Posts: 4
|
 Re: Problem with inline functions in 1.93
Gary Samad I'm using the "inline" statement because I found I need it.
For example I have a fuction that handles a Mindsensors "DIST-Nx-Long-v2" sensor reading the distance. That function is called from more that one task. I'm using the same sensor for different things.
Pure C programming is one thing. But when we start controling hardware things complicate.
|
| Sun Jul 18, 2010 7:30 pm |
|
 |
|
Aswin
Expert
Joined: Mon Oct 06, 2008 6:30 pm Posts: 176 Location: Netherlands
|
 Re: Problem with inline functions in 1.93
You can start a seperate task to address the sensor and store its results in a global variable. btw. Inline might no longer be supported, it is still suggested by the compiler!
_________________My most recent blog: A grain of sugar
|
| Wed Oct 13, 2010 8:11 am |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Problem with inline functions in 1.93
If you are compelled to use inline functions, you can always do this:
|
| Thu Nov 11, 2010 3:32 pm |
|
|
|
Page 1 of 1
|
[ 14 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|