Solved

limit of nesting

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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.

746 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

14 Experts available now in Live!

Get 1:1 Help Now