Solved

limit of nesting

Posted on 2006-11-23
3
320 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

862 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now