I get this message when compiling my program. It's about 25KB big, and MC have 32KB... What should I do to compile bigger programs anway, because program is not completed yet, I have to add some more stuff.
Have you checked the description of this in the Manual?
You can get online help on errors straight from uVision:
http://www.keil.com/uvision/ide_ov_help.asp
You can also look up all the error codes in the appropriate tool manual; eg, for C51:
http://www.keil.com/support/man/docs/c51/c51_errors.htm
You haven't given the full message, so it's hard to tell.
Please post the full text of the entire message - use copy and paste; do not manually re-type it.
Anyhow - it sounds like you have crashed the compiler!
"The parse stack has overflowed. This can occur if the source program contains extremely complex expressions or if blocks are nested more than 31 levels deep."
So, what the heck does this mean? And how to prevent it?
"So, what the heck does this mean?"
I think it means exactly what it says!
"And how to prevent it?"
Don't do the things that it tells you may cause the error; ie,
1. Do not use extremely complex expressions;
2. Do not nest blocks more than 31 levels deep.
"1. Do not use extremely complex expressions;"
I don't use.
"2. Do not nest blocks more than 31 levels deep."
What does this mean? (English is not my native language.) What is nest in C?
25KB big compiled programme HAVE to be big and complex in C. Can you emagine how big is source C file to get 25KB compiled od MC51? It is about 200KB...
How long is your longest line ? How long is your longest expression (in characters) ?
What is nest in C?
Blocks in C are delimited by curly braces {}. This example contains two blocks, one of them nested in the other:
if(somecondition) { do_stuff(); for(somevariable = 0; somevariable < 16; somevariable++) { do_more_stuff(); } }
25KB big compiled programme HAVE to be big and complex in C.
The maximum nesting depth has absolutely nothing to do with how large the program is. It merely depends on how unmaintainable the programmer wants to make his "creation".
OK. Thank you. Then 2 is negative. I don't have 32 level deep nesting...
So the question remains: How complex is too complex? :)
Compile every source file separately to find the file that is causing the problem, then have a good look at it.
"I don't have 32 level deep nesting"
Maybe you don't intend to, but it can be quite easy to achieve by accident!
eg, if you forget a closing brace, the next opening brace is then effectively another level of nesting...
similarly, if you are playing preprocessor tricks, and one of your macro expansions is broken, it could lead to similar effects...
"find the file that is causing the problem, then have a good look at it."
And if you can't see it, remove half of the source code: if the error persists, then you know that it's in the remaining half of the source; if the error goes away, then it's probably in the half that you removed.
Repeat as necessary!
"How long is your longest expression (in characters) ?"
Number of characters is not directly relevant.
More important is things like number of operators, function calls, brackets...
Note that "nesting" also applies to brackets (parentheses) - the following expression contains (redundant) nested parentheses:
x = ( (a) + (b) )
"English is not my native language. What is nest in C?"
Fair enough - but it would have been more helpful to say specifically what you didn't understand, rather than just "what the heck does this mean?"
"Nesting" is a very common term in programming - it refers to one thing being "enclosed within" another; eg, brackets within brackets are said to be "nested"
"25KB big compiled programme HAVE to be big and complex in C."
Many would say that 25K is actually a very small program...
Although the overall program may be "complex", that doesn't mean that individual lines or expressions within the program need to be complex.
Some 'C' programmers seem to feel a need to cram as much as possible into every single source line - this is unnecessary and usually counterproductive.
Not directly ... however, it is easier to cram a complex expression into 500 characters than into 72.
"What does this mean? (English is not my native language.) What is nest in C?"
See my last post (10-Mar-2006 02:56) in this thread: http://www.keil.com/forum/docs/thread7364.asp
This does seem to be a frequent problem - so do Keil (ARM) need to consider using simplified English in their error messages? Or should they provide translations for error messages? If so, what languages? Maybe this is a service that local distributors could provide?
Thank you guys...
I have solved the problem. It seems that compiler have some bugs...
The problem was to many if > else if > ... > else if parsing in one block...
It seems that compiler have some bugs
No, it doesn't, because ...
... that is nesting, too. Under certain circumstances, C blocks don't need to be enclosed in parentheses - and this is one of them. Every else if introduces an additional level of nesting, because the else refers to the preceding if, not to the first if.
With indentation, this becomes a little clearer:
if(...) ... else if(...) ... else if(...) ... else if(...) ... else if(...) ...
This happens because C does not have an "elseif" that would place all additional cases at the same level of nesting as the first if.