Pages: [1]   Go Down
Author Topic: Counter++  (Read 748 times)
0 Members and 1 Guest are viewing this topic.
Houston Area
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
           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]; 
            }
        }
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 53
Posts: 1799
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
switch( ++counter ){
Logged


0
Offline Offline
Full Member
***
Karma: 1
Posts: 225
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

New Jersey
Online Online
Faraday Member
**
Karma: 50
Posts: 3426
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: