Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error :: C1061 compiler limit : blocks nested too deeply

Error :: C1061 compiler limit : blocks nested too deeply

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 7 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, in my program this error C1061 compiler limit : blocks nested too deeply comes,i m using number of if else,please tell me how can i resolve this, thanks in advance.

    C M 2 Replies Last reply
    0
    • L Le rner

      Hi all, in my program this error C1061 compiler limit : blocks nested too deeply comes,i m using number of if else,please tell me how can i resolve this, thanks in advance.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Without seeing your code it is hard to tell, genericly you can either try to re-structure the whole thing, or divide it into multiple functions, or, if everything else fails, -oh my i hope no lightning will strike me now *ducks and covers*- use goto, but as said, without seeing actual code, it is hard to say...

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      L 1 Reply Last reply
      0
      • L Le rner

        Hi all, in my program this error C1061 compiler limit : blocks nested too deeply comes,i m using number of if else,please tell me how can i resolve this, thanks in advance.

        M Offline
        M Offline
        Moak
        wrote on last edited by
        #3

        Please show source code or simplify nesting by refactoring. Have a good weekend.

        Chat in Europe :java: Now with 24% more Twitter

        1 Reply Last reply
        0
        • C Code o mat

          Without seeing your code it is hard to tell, genericly you can either try to re-structure the whole thing, or divide it into multiple functions, or, if everything else fails, -oh my i hope no lightning will strike me now *ducks and covers*- use goto, but as said, without seeing actual code, it is hard to say...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          L Offline
          L Offline
          Le rner
          wrote on last edited by
          #4

          I have a TreeCtrl,with number of Tree items. get currently selected tree item and perform function on it respectively.

          CString Tree_str;
          BOOL flag;

          if(Tree_str==_T("Item 1"))
          {
          if(flag==TRUE)
          {
          //do dome work
          }
          else if(flag==FALSE)
          {
          //do dome work
          }
          }

          else if(Tree_str==_T("Item 2"))
          {
          if(flag==TRUE)
          {
          //do dome work
          }
          else if(flag==FALSE)
          {
          //do dome work
          }
          }

          .
          .
          .
          .

          else if(Tree_str==_T("Item 140"))
          {
          if(flag==TRUE)
          {
          //do dome work
          }
          else if(flag==FALSE)
          {
          //do dome work
          }
          }

          L M L D 4 Replies Last reply
          0
          • L Le rner

            I have a TreeCtrl,with number of Tree items. get currently selected tree item and perform function on it respectively.

            CString Tree_str;
            BOOL flag;

            if(Tree_str==_T("Item 1"))
            {
            if(flag==TRUE)
            {
            //do dome work
            }
            else if(flag==FALSE)
            {
            //do dome work
            }
            }

            else if(Tree_str==_T("Item 2"))
            {
            if(flag==TRUE)
            {
            //do dome work
            }
            else if(flag==FALSE)
            {
            //do dome work
            }
            }

            .
            .
            .
            .

            else if(Tree_str==_T("Item 140"))
            {
            if(flag==TRUE)
            {
            //do dome work
            }
            else if(flag==FALSE)
            {
            //do dome work
            }
            }

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            This is nowhere near deep enough to generate that message, I suspect something else is wrong with your source. [edit]Something for the weekend? ... MuraliKrishnaP spotted the obvious point that I missed, which is that you have exceeded the 128 nest limit because of the number of if .. else if statements.[/edit]

            It's time for a new signature.

            modified on Saturday, August 7, 2010 9:32 AM

            1 Reply Last reply
            0
            • L Le rner

              I have a TreeCtrl,with number of Tree items. get currently selected tree item and perform function on it respectively.

              CString Tree_str;
              BOOL flag;

              if(Tree_str==_T("Item 1"))
              {
              if(flag==TRUE)
              {
              //do dome work
              }
              else if(flag==FALSE)
              {
              //do dome work
              }
              }

              else if(Tree_str==_T("Item 2"))
              {
              if(flag==TRUE)
              {
              //do dome work
              }
              else if(flag==FALSE)
              {
              //do dome work
              }
              }

              .
              .
              .
              .

              else if(Tree_str==_T("Item 140"))
              {
              if(flag==TRUE)
              {
              //do dome work
              }
              else if(flag==FALSE)
              {
              //do dome work
              }
              }

              M Offline
              M Offline
              MuraliKrishnaP
              wrote on last edited by
              #6

              The following code

              if(a)
              {
              }
              else if (b)
              {
              }
              else if(c)
              {
              }
              

              is nothing but

              if(a)
              {
              }
              else 
              {
              	if (b)
              	{
              	}
              	**else // how deep this can go? 128? not sure.**
              	{
              		if(c)
              		{
              		}
              	}
              }
              

              else, you can also do like this. Will this solve your problem?

              if(a)
              {
              	if(flag)
              	{
              		// do work
              	}
              	else
              	{
              		// do work
              	}
              }
              
              if(b)
              {
              }
              
              if(c)
              {
              }
              
              1 Reply Last reply
              0
              • L Le rner

                I have a TreeCtrl,with number of Tree items. get currently selected tree item and perform function on it respectively.

                CString Tree_str;
                BOOL flag;

                if(Tree_str==_T("Item 1"))
                {
                if(flag==TRUE)
                {
                //do dome work
                }
                else if(flag==FALSE)
                {
                //do dome work
                }
                }

                else if(Tree_str==_T("Item 2"))
                {
                if(flag==TRUE)
                {
                //do dome work
                }
                else if(flag==FALSE)
                {
                //do dome work
                }
                }

                .
                .
                .
                .

                else if(Tree_str==_T("Item 140"))
                {
                if(flag==TRUE)
                {
                //do dome work
                }
                else if(flag==FALSE)
                {
                //do dome work
                }
                }

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                You can turn that into a regular switch, here is the scenario in pseudo-code:

                int n=extract the number from string Tree_str;
                switch (n) {
                case 1:
                ...
                break;
                case 2:
                ...
                break;
                ...
                }

                it will result in less code and faster execution! :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                1 Reply Last reply
                0
                • L Le rner

                  I have a TreeCtrl,with number of Tree items. get currently selected tree item and perform function on it respectively.

                  CString Tree_str;
                  BOOL flag;

                  if(Tree_str==_T("Item 1"))
                  {
                  if(flag==TRUE)
                  {
                  //do dome work
                  }
                  else if(flag==FALSE)
                  {
                  //do dome work
                  }
                  }

                  else if(Tree_str==_T("Item 2"))
                  {
                  if(flag==TRUE)
                  {
                  //do dome work
                  }
                  else if(flag==FALSE)
                  {
                  //do dome work
                  }
                  }

                  .
                  .
                  .
                  .

                  else if(Tree_str==_T("Item 140"))
                  {
                  if(flag==TRUE)
                  {
                  //do dome work
                  }
                  else if(flag==FALSE)
                  {
                  //do dome work
                  }
                  }

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Shave the levels down to 123 or less.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Man who follows car will be exhausted." - Confucius

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups