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 / 738
737  |  739
Subject: 
NXC - embedded functions failed
Newsgroups: 
lugnet.robotics.nxt
Date: 
Sun, 20 May 2007 17:19:29 GMT
Viewed: 
19803 times
  
#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);

         NumOut(5,LCD_LINE3,false,Prob);  // returns 33  GOOD

---------------------------------

    Wait(10000);

}









--
MIME ATTACHMENTS DISCARDED:

1.  Content-Type: text/html;
    charset="us-ascii"
    Content-Transfer-Encoding: quoted-printable
    Content-Length: 4672



Message has 2 Replies:
  Re: NXC - embedded functions failed
 
(...) 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 (...) (17 years ago, 21-May-07, to lugnet.robotics.nxt)
  RE: NXC - embedded functions failed
 
Hi John, Will throwing in a compilation error be a viable option? --Elizabeth -----Original Message----- From: news-gateway@lugnet.com [mailto:news-gateway...ugnet.com] On Behalf Of Elizabeth Mabrey Sent: Sunday, May 20, 2007 1:19 PM To: (...) (17 years ago, 21-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
    

Custom Search

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