?
Solved

limit of nesting

Posted on 2006-11-23
3
Medium Priority
?
348 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 200 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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

764 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