c++ compiling issues in 1.6.3, atmel 328 chip

hey all, did anyone come across compiling issues with for example: count++ counters?

I had a structure working good in older arduino releases with counters using the "++" adding.

I have a board with an atmel 328PU chip on it. it used to work ok, but now I compiled and uploaded it through 1.6.3 and there were no error messages during compiling, but the program itself gave errors when it ran on the chip. there are some more issues with frequency measuring, however I am not sure yet what this is, still testing it, it used to work ok before.

thanks for any reply. BR, Herman

it used to work ok before.

What did? You seem to have forgotten to post your code.

I had a structure working good in older arduino releases with counters using the "++" adding.

Indeed?

Read this before posting a programming question

How to use this forum

Please post the code as well as the output it generates.

The ++ operator works the same was as always :-P

Some other things have changed going to 1.6.x, though most of those should produce compiler errors, not odd behavior.

Some other things have changed going to 1.6.x, though most of those should produce compiler errors, not odd behavior.

One of the things that DOES produce odd behavior is this stupid code:

count = count++;

Why do I suspect that OP is doing that?

Why do I suspect that OP is doing that?

Little old mind reader you.

But ... he hasn't posted any code!

Let alone that little snippet which has undefined results.

... but the program itself gave errors when it ran on the chip.

Classic symptoms of undefined behaviour.

PaulS: One of the things that DOES produce odd behavior is this stupid code:

count = count++;

Why do I suspect that OP is doing that?

And todays award for most excellent clairvoyance goes to PaulS :) . Herman01 - google out 'post increment operator' re 'order of evaluation of side effects'. Actually, I have done it for you:

http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/

They give another example of what not to do:

foo(x, x++);

Also see:

http://en.wikipedia.org/wiki/Sequence_point

http://c-faq.com/expr/seqpoints.html

http://en.wikipedia.org/wiki/Undefined_behavior

And give PaulS some karma. ;)

Thanks for the explanations and links.
I guess you have given the answers already, here is (part of) the code.

Some background: I use it on a self made board with an atmel 328 pu. The board functions as a quickshifter (temperary ignition kill) unit on my motorcycle. It measures a sensor in my shift linkage, the frequencies of tacho and speed, throttle position, clutch engagement. An LCD display shows the output of several values, an led array flashing above a set rpm and a 7-segment gear indicator display.

To adjust characteristics, a menu can be entered where a number of values can be tuned.
When entering the menu the LCD display showed a ‘0’ on the second row.

I would like to share the whole program with you, is it possible to attached the whole program to this thread?

As you can see, indeed the count = count++; is used. when changed to count = count + 1; it suddenly works again.

// run setup menu to adjust values and write to eeprom
void menu() { 
  for (count=0; count<11;) {
    count = count + 1; 
    lcd.clear(); lcd.setCursor(0, 0);
    if (count > 0 && count < 6) {
      lcd.print("MENU: Shifttime");
      lcd.setCursor(0, 1); lcd.print("ST G"); lcd.print(count); lcd.print("= ");
      lcd.setCursor(13, 1); lcd.print("ms ");
      if (count == 1) { value = shifttime1; }
      if (count == 2) { value = shifttime2; }
      if (count == 3) { value = shifttime3; }
      if (count == 4) { value = shifttime4; }
      if (count == 5) { value = shifttime5; }
      plusmin = 10;
      maxval = 250;
    }
    if (count == 6) {
      lcd.print("MENU: Threshold");
      lcd.setCursor(0, 1); lcd.print("Thr=");
      lcd.setCursor(13, 1); lcd.print("mV ");
      value = threshold;
      plusmin = 50;
      maxval = 1000;
    } 
    if (count == 7) {
      lcd.print("MENU: Holdtime  ");
      lcd.setCursor(0, 1); lcd.print("HT =");
      lcd.setCursor(13, 1); lcd.print("ms ");
      value = holdtime;
      plusmin = 10;
      maxval = 250;

quickyV1_1.ino (19.4 KB)

Kudos to PaulS for guessing without even seeing any code! The compiler is behaving correctly.

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

Ok, post is modified, and the program is attached. Do not kill me on programming skills, I am not a professional... :confused:

Again thanks for the tips and Karma is up for you guys!

P.S. The corrected code is shown in the modified post. So "count = count++; is changed to count = count + 1;

So "count = count++; is changed to count = count + 1;

Or, simply:

count++;