blocks nested too deeply

This is a discussion on blocks nested too deeply within the C Programming forums, part of the General Programming Boards category; I am trying to compile a source, but I get the error "Blocks nested too deeply". I would swear, though, ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    39

    blocks nested too deeply

    I am trying to compile a source, but I get the error "Blocks nested too deeply". I would swear, though, that the nest level of the if block does not exceed six or seven. How to fix this?

  2. #2
    verbose cat
    Join Date
    Jun 2003
    Posts
    209
    Based on that error message, the most likely way to fix it is to re-think your design. But we can only guess if you don't show us any code.
    abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,627
    Quote Originally Posted by MK27
    Have you seen this?

    BUG: Too many unnested loops incorrectly causes a C1061 compiler error in Visual Studio .NET
    Heheh. That said, that many loops in a single function is likely to be very poor programming practice as well.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305
    Thats crazy !!!!!!!!

    I cant imagine a program with 250 nested loops ..... (one inside another one inside another)

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    vril: How many levels of nested loops do you have?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by roaan View Post
    Thats crazy !!!!!!!!

    I cant imagine a program with 250 nested loops ..... (one inside another one inside another)
    It says "unnested loops" -- ie, if you have for (i=0;i<10;i++); 250 times in one function, you will get the erroneous error.

    Kind of agree with laserlight that that borders on obscene anyway.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305
    Quote Originally Posted by MK27 View Post
    It says "unnested loops" -- ie, if you have for (i=0;i<10;i++); 250 times in one function, you will get the erroneous error.

    Kind of agree with laserlight that that borders on obscene anyway.
    Thanks MK27 for correcting me out. I was really stumbled on how could anyone fathom 250 levels of nesting and still understand what is going on.

  9. #9
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by roaan View Post
    Thanks MK27 for correcting me out. I was really stumbled on how could anyone fathom 250 levels of nesting and still understand what is going on.
    I have been reading a little about compiler internals over the summer and that is pretty much how I feel about that (although as far as I have observed, even in large and complex sources, the individual functions are never very long).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #10
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305
    Quote Originally Posted by vril View Post
    I am trying to compile a source, but I get the error "Blocks nested too deeply". I would swear, though, that the nest level of the if block does not exceed six or seven. How to fix this?
    Hi , Can you post the code which was generating this error?

  11. #11
    Registered User
    Join Date
    Aug 2009
    Posts
    39
    The code is chaotic and I claimed nowhere that it belongs to me. I am informed about the 250 limit, which cannot but surprise me, since the nest level is not more than 6-7 inlaid blocks.

  12. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Even old Turbo C ver. 1.01 for DOS (16 bits only) can next 81 levels deep, if you spread it across 8 or 9 functions.

    What compiler are you using? Does any of the blocks call other blocks/functions, recursively?

    Six or 7 levels deep doesn't seem right, but there are a few compilers that are mostly jokes out there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nested array vs. tree
    By KONI in forum Tech Board
    Replies: 1
    Last Post: 06-07-2007, 04:43 AM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 04:01 PM
  3. nested switch issue
    By fsu_altek in forum C Programming
    Replies: 3
    Last Post: 02-15-2006, 09:29 PM
  4. Problem constructing a class with a nested struc
    By pliang in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2005, 07:43 PM
  5. Nested Classes
    By manofsteel972 in forum C++ Programming
    Replies: 4
    Last Post: 11-21-2004, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21