"expected unqualified id before 'bool' " in a for

Hello,

I'm converting a date string into a tm structure (then a time_t type) and I'm using a for to determinate the number of days that passed before the current month but Arduino seems not to like my idea.
isn't the following syntax valid for the arduino compilator or am I doing something wrong ?

  bool bisxl = ((startTime.tm_year + 1900) % 4) ? 0 : 1; // is the current year a bisextile year
  uint8_t J = 31, // months with 31 days
          F = 28 + bisxl, //nb of days in February
          A = 30; // months with 30 days 

  // count the number of days that passed before the current month.
  for(int i = 0, bool b = true, nbDay = 0; i != startTime.tm_mon ; i++, nbDay += ((i == 1) ? 28 : (30 + b)) + bisxl, b ~= b){
  // i     : month tested
  // nbDay : total of days that passed before the month i
  // b     : is the month a 31 or 30 month
      if(i == 7)
        b ~= b;
  }
  startTime.tm_yday = nbDay + startTime.tm_mday;

Please post your code and the error message you're seeing.

  for(int i = 0, bool b = true, nbDay = 0;

The initializer clause allows you to define any number of variables, but they must ALL be of the same type. You can not have multiple types in the initializer clause.

Why on earth do you need an int to count up to 31?

b ~= b;

Don't think it's your error but that line is definitely rubbish. What did you mean for that to do?

PaulS:
The initializer clause allows you to define any number of variables, but they must ALL be of the same type. You can not have multiple types in the initializer clause.

Owh Thank you, I didn't know that ! I'll remember.

PaulS:
Why on earth do you need an int to count up to 31?

:grinning: I'm working as a research engineer and here, the number one rule is "meh, It's just a model, the final version will be subcontracted"
but you're right I should keep a rigorous mind !

Delta_G:
What did you mean for that to do?

As it is a boolean, isn't it equivalent to the following?

b = !b;

As it is a boolean, isn't it equivalent to the following?
Code: [Select]
b = !b;

What does the ~ operator do?
What does the ! operator do?

It isn't equivalent. True is 1. ~1 is -2 which would still evaluate as true.