Solved

limit of nesting

Posted on 2006-11-23
3
332 Views
Last Modified: 2010-04-01
Is there any limit of nesting?
0
Comment
Question by:fatimao
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 50 total points
ID: 18006363
afaik the MINIMUM nesting limit is (ie. nested {}'s) :

    C89 : 15 levels
    C99 : 127 levels
    C++ : 256

A compiler can use a higher level though.

If you wanted to know about function calls instead, that's limited by the stack size.
0
 

Author Comment

by:fatimao
ID: 18012133
so if i am right these limits are decided and finalized while a language is being designed.

what happens if we write a code that exceeds the limit of nested {}'s ... will that be considered as syntax error ...
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 18012195
>> so if i am right these limits are decided and finalized while a language is being designed.
The LOWER limits are prescribed by the C and C++ standards. The specific limit used by your compiler is decided by the compiler, but should be greater than or equal to the lower limit in the standard.

>> what happens if we write a code that exceeds the limit of nested {}'s ... will that be considered as syntax error ...
That depends on your compiler. It might geherate a syntax error, or a runtime error.

In any case, any C++ code that uses more than 256 nested levels is not very good code. 256 is a LOT and very generous !!
If you intend to write code that is gonna approach these limits, think about re-designing your code !
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question