LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-08-2013, 01:28 AM   #1
tfnc99
Member
 
Registered: Sep 2012
Posts: 58

Rep: Reputation: Disabled
Is it safe to not put break; if you have brackets? C++


Well normally I would just put in break to be safe, but here I am working with large amounts of generated code, and the utilities I use to format and create this code are... Slow and very hands-on, .

So basically these are very large 3-tier switch statements, totaling around 700 different cases. I forgot to add break to the generator but I did remember brackets.

Assuming none of the things the switch cases check for are changed in any of the cases, is it safe to leave out these breaks or am I going to have to go back to square one with this?
 
Old 03-08-2013, 01:39 AM   #2
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
If a matching expression is found, control is not impeded by subsequent case or default labels. The break statement is used to stop execution and transfer control to the statement after the switch statement. Without a break statement, every statement from the matched case label to the end of the switch, including the default, is executed.
http://msdn.microsoft.com/en-au/libr...=vs.80%29.aspx
 
1 members found this post helpful.
Old 03-08-2013, 02:12 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Take time, get it right, then relax
 
  


Reply

Tags
c++, switch



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Netbeans 7.3: Program does not break at break points when debugging JavaScript OtagoHarbour Programming 0 02-22-2013 02:44 AM
Put Safe Mode Off Slackervaara Mandriva 4 08-19-2012 06:43 AM
Sed and brackets unihiekka Linux - Newbie 9 10-09-2010 11:08 PM
Is it safe to put Trixbox on public IP? depam Linux - Software 1 12-14-2006 06:39 PM
Kmail--Unbalanced Brackets mooreted Linux - Software 4 01-14-2005 07:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration