I'm running a couple of inline functions to determine minimum and maximum values, and I'm getting an error that says "variable name expected" for the functions...any ideas as to why it isn't working? (I got these functions from Power Programming)
I'd rather use #defines, as we don't have voids as function parameters yet. This ensures "compatibility" (call it what you will) between all types which support the < and > operators:
muntoo,
I don't understand what should be better with your #inline definition and *our* inline int or inline float? Can you give me some programming examples?
I don't know if I understand you correctly, but I guess what you might mean is:
if we use
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
we will be not limited to any pre-defined varible types like int, long, float, this macro will work with each variable type for each macro call - correct?
doc-helmut wrote:we will be not limited to any pre-defined varible types like int, long, float, this macro will work with each variable type for each macro call - correct?
Yeah, that's what I mean.
Commit to LEGO Mindstorms Robotics Stack Exchange: bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
#define min3(a, b, c) (a < b) ? ((a < b) ? a : c) : ((b < c) ? b : c)
#define max3(a, b, c) (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c)
I use these and the ones in the earlier post in my driver suite.
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)