The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
![]() |
2014-06-12
, 01:05
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#2
|
- Add a declaration of something involved at the beginning of the function. It does not need to be used, as long as the con/destructor is being called. An int was not enogh, but e.g. an QStringList did the trick.
- Split the string literal in one of the blue lines to something like QString("k") + "Hz".
- Change switch(index) to switch(index+1), with obvious changes to the case labels.
if (index == FREQUENCY) { // Add the Hz items } else { // Add the Seconds items }
The Following User Says Thank You to Copernicus For This Useful Post: | ||
![]() |
2014-06-12
, 04:48
|
Posts: 254 |
Thanked: 509 times |
Joined on Nov 2011
@ Canada
|
#3
|
![]() |
2014-06-12
, 07:35
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#4
|
The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
![]() |
2014-06-12
, 08:52
|
|
Posts: 878 |
Thanked: 2,535 times |
Joined on Feb 2012
@ Germany
|
#5
|
here's an interesting description of why to be wary of the switch statement
![]() |
2014-06-12
, 11:20
|
Posts: 2,154 |
Thanked: 8,464 times |
Joined on May 2010
|
#6
|
![]() |
2014-06-12
, 12:06
|
|
Posts: 1,986 |
Thanked: 7,698 times |
Joined on Dec 2010
@ Dayton, Ohio
|
#7
|
It is also possible to use enum instead of switch.
Maybe this is interesting.
http://schneide.wordpress.com/2010/1...itch-use-enum/
class indexType { public: virtual void addItems() = 0; }; class frequency: public indexType { public: void addItems(); // Add the Hz items }; class period: public indexType { public: void addItems(); // Add the Seconds items };
The Following 2 Users Say Thank You to Copernicus For This Useful Post: | ||
![]() |
2014-06-12
, 14:10
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#8
|
static void refillComboBox (QComboBox *combo, const QString items[], int number_of_items, int selected_item);
#define ITEMS(x) sizeof x / sizeof x[0] static const QString foo[] = { "Hz", "kHz" }; refillComboBox(ui.comboBlaBlaBla, foo, ITEMS(foo), 0 }; static const QString bar[] = { micro + "s", "ms", "s" }; refillComboBox(ui.comboBlaBlaBla, bar, ITEMS(bar), 3 };
The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
Now here comes the interesting part. Various vays of editing the code got rid of the error:
- Add a declaration of something involved at the beginning of the function. It does not need to be used, as long as the con/destructor is being called. An int was not enogh, but e.g. an QStringList did the trick.
- Split the string literal in one of the blue lines to something like QString("k") + "Hz".
- Change switch(index) to switch(index+1), with obvious changes to the case labels.
What did not work:All this points me in the direction of code size. In all cases that fixed the problem, a significant amount of additional code was generated or removed. My theory is that the compiler generates the code in multiples of X bytes and adds padding as necessary, and that the orn r3,r3,#127 instruction is somehow involved in that. Adding or removing enough code changes the padding and avoids using the instruction.
Does anyone have a better explanation or, better still, a solution? I am using gcc 4.6.1 from extras-devel, if that makes any difference, and am using the CFLAGS trick suggested here to build Qt on the phone. Perhaps another flag is required?