Go Down

Topic: Counter++ (Read 1 time) previous topic - next topic

RandyMan

Something strange, at least I think so.
If have the "counter++" or the case statement in the sketch,  the sketch compiles to 27146 bytes.
If I have both then it compiles to 27560.
Big jump. Wonder why since I need all the room I can get.

I have not included the entire sketch.

Code: [Select]
           counter++;
                   
        switch (counter) {
          case 3:
            for (int j =0; j < 13; j++) {                                    //
              sub_upc[j] = csv_value[j]; 
            }
            break;
          case 4: 
            for (int j =0; j < 5; j++) {                                    //
              query_status[j] = csv_value[j]; 
            }
            break;
          case 9: 
            for (int j =0; j < 13; j++) {                                    //
              upc12[j] = csv_value[j]; 
           }
           break; 
          case 12: 
            for (int j =0; j < FIELD_LENGTH; j++) {                                    //
              product[j] = csv_value[j]; 
            }               
            break;
          case 13: 
            for (int j =0; j < FIELD_LENGTH; j++) {                                    //
              description[j] = csv_value[j]; 
            } 
            break;
          case 14: 
            for (int j =0; j < 4; j++) {                                    //
              category_no[j] = csv_value[j]; 
            } 
            break;
          case 15:
            for (int j =0; j < 20; j++) {                                    //
              category_text[j] = csv_value[j]; 
            }
        }

pYro_65

Use pre-increment instead, I don't really see what you are trying to do... Don't you need both for the code to work

Code: [Select]
switch( ++counter ){

Professor Chaos

Possibly code being optimized away - particularly if the counter variable doesn't get changed elsewhere.

wildbill

Not sure what's causing your issue, but does replacing those for loops with calls to memcpy make the sketch any smaller?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy