Solved

limit of nesting

Posted on 2006-11-23
3
335 Views
Last Modified: 2010-04-01
Is there any limit of nesting?
0
Comment
Question by:fatimao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

734 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