To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 740
739  |  741
Subject: 
Re: NXC - embedded functions failed
Newsgroups: 
lugnet.robotics.nxt
Date: 
Mon, 21 May 2007 16:22:11 GMT
Viewed: 
20411 times
  
In lugnet.robotics.nxt, Elizabeth Mabrey wrote:
         Prob = Max(33, Max(5,15));

         NumOut(5,LCD_LINE2,false,Prob);  //returns 15  WRONG

This is definitely a problem in NXC.  The problem is that the value of arg "a"
(33) to the function Max is being replaced during the second call to Max since
it passes 5 into arg "a".  It looks like I need to figure out a decent way to
implement an argument stack which is probably going to be excruciatingly
difficult.

If anybody has some really good ideas about this sort of thing I am open to
suggestions.

John Hansen



Message is in Reply To:
  NXC - embedded functions failed
 
#include "NXCDefs.h" int Max(int a,int b){ if (a>b) return a; else return b; } task main(){ int Prob=0; Prob = Max(33, Max(5,15)); NumOut(5,LCD_LINE2,false,Prob); //returns 15 WRONG ---...--- Prob = Max(5,15); Prob = Max(33,Prob); (...) (18 years ago, 20-May-07, to lugnet.robotics.nxt)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in NXT programmable brick

 
Verified and Trusted Team of Hackers
11 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR