NXC: a<b? c: d // ==>> compiler error

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

NXC: a<b? c: d // ==>> compiler error

Post by HaWe »

hi,
I'm getting a compiler error with this line:

Code: Select all

int SoundLevel, BGrndNoise, p;
SoundLevel<BGrndNoise ? p++ : p=0;
# Error: Invalid assignment
File "c:\Temp\temp.nxc" ; line 43
# SoundLevel<B
#----------------------------------------------------------
# Error: ';' expected
File "c:\Temp\temp.nxc" ; line 43
# SoundLevel<B
#----------------------------------------------------------
what may be wrong (Bricxcc 3.3.8.9. 2010-11-03)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC: a<b? c: d // ==>> compiler error

Post by afanofosc »

Seems like this is not a supported form of the ?: expression as I implemented it in NXC. Try this instead:

Code: Select all

  p = SoundLevel<BGrndNoise ? p+1 : 0;
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: a<b? c: d // ==>> compiler error

Post by HaWe »

thx, this works :)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests