A
adelfino
Hi! I'm pretty new to C and I'am getting an error from GCC 4.0 with the
following function:
unsigned int search_for_clo_tag (const unsigned char *array, const
unsigned int array_element) {
unsigned char clo_tag;
unsigned int i;
unsigned char ope_tags[1];
switch (*(array + array_element)) {
case '(':
clo_tag = ')';
*ope_tags = '[';
*(ope_tags + 1) = '{';
break;
case '[':
clo_tag = ']';
*ope_tags = '(';
*(ope_tags + 1) = '{';
break;
case '{':
clo_tag = '}';
*ope_tags = '(';
*(ope_tags + 1) = '[';
break;
}
for (i = 1; *(array + array_element + i) != '\0'; i++)
switch (*(array + array_element + i)) {
case *(array + array_element): case *ope_tags: case *(ope_tags + 1):
if (!must_be_ignored (array, array_element + i))
i = search_for_clo_tag (array, array_element + i) - array_element;
break;
case clo_tag:
if (!must_be_ignored (array, array_element + i))
return array_element + i;
break;
}
}
The error is: "case label does not reduce to an integer constant" and
its related to the second switch. I don't understand why this happen,
since chars are integers, right?
Well, hope you can help me. Thank you and good luck!
PS: Sorry my English. I'am from Argentina,
following function:
unsigned int search_for_clo_tag (const unsigned char *array, const
unsigned int array_element) {
unsigned char clo_tag;
unsigned int i;
unsigned char ope_tags[1];
switch (*(array + array_element)) {
case '(':
clo_tag = ')';
*ope_tags = '[';
*(ope_tags + 1) = '{';
break;
case '[':
clo_tag = ']';
*ope_tags = '(';
*(ope_tags + 1) = '{';
break;
case '{':
clo_tag = '}';
*ope_tags = '(';
*(ope_tags + 1) = '[';
break;
}
for (i = 1; *(array + array_element + i) != '\0'; i++)
switch (*(array + array_element + i)) {
case *(array + array_element): case *ope_tags: case *(ope_tags + 1):
if (!must_be_ignored (array, array_element + i))
i = search_for_clo_tag (array, array_element + i) - array_element;
break;
case clo_tag:
if (!must_be_ignored (array, array_element + i))
return array_element + i;
break;
}
}
The error is: "case label does not reduce to an integer constant" and
its related to the second switch. I don't understand why this happen,
since chars are integers, right?
Well, hope you can help me. Thank you and good luck!
PS: Sorry my English. I'am from Argentina,