Hi All,
I saw in some code
do{//for error jump
/*Some code here*/
}while(0);
Can anyone plese tell me what is the purpose of this code? There was a
comment saying that //for error jump. What does it mean? There is no
error related code inside the do-while block. I guess the comment
specifies the reason for that block.
Regards,
Mohan. 4 1425
"Mohanasundaram " <mo************ @msn.com> wrote in message
news:9b******** *************** ***@posting.goo gle.com... Hi All,
I saw in some code
do{//for error jump /*Some code here*/ }while(0);
Can anyone plese tell me what is the purpose of this code? There was a comment saying that //for error jump. What does it mean? There is no error related code inside the do-while block. I guess the comment specifies the reason for that block.
Regards, Mohan.
Hello,
This is used to break out of a code in case of errors...consid er this:
do
{
/* ....... */
if (!someFunction( ))
break;
/* .... */
if (!someChecks())
break;
/* ......*/
} while (0);
/* put here some de-initialization code */
Follow this thread for more info: http://groups.google.com/groups?hl=e...fe=off&frame=r
ight&th=b90082f 332d8b543
--
Elias mo************@ msn.com (Mohanasundaram ) wrote: I saw in some code
do{//for error jump /*Some code here*/ }while(0);
Can anyone plese tell me what is the purpose of this code?
The purpose of this code is to write spaghetti code, yet at the same
avoiding the use of goto to satisfy the anal-retentive reviewers.
IOW, it's an illegible botch. If you need a goto, damn well use one.
Richard
Mohanasundaram wrote: Hi All,
I saw in some code
do{//for error jump /*Some code here*/ }while(0);
Can anyone plese tell me what is the purpose of this code? There was a comment saying that //for error jump. What does it mean? There is no error related code inside the do-while block. I guess the comment specifies the reason for that block.
Richard Bos' comments notwithstanding , this idiom is more commonly seen in debug
macros to avoid dangling else clauses, and to introduce a new scope.
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown
David Rubin <no****@nowhere .net> wrote: Mohanasundaram wrote:
do{//for error jump /*Some code here*/ }while(0);
Can anyone plese tell me what is the purpose of this code? There was a comment saying that //for error jump. What does it mean? There is no error related code inside the do-while block. I guess the comment specifies the reason for that block.
Richard Bos' comments notwithstanding , this idiom is more commonly seen in debug macros to avoid dangling else clauses, and to introduce a new scope.
It is rarely seen with that comment in macros (where, you are correct,
it _is_ useful), and to introduce a new scope a simple pair of braces
suffices.
Richard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lars Plessmann |
last post by:
Problem: I try to store data in a objects field and read it out again.
Sounds easy, yeah. But its a bit tricky here.... ;-)
This is the class Customer.php with some setter and getter functions to
store customers data within an object.
It works.
Furthermore, it includes a synchronize method, which calls the
individual setXXX function and takes the data
from the $_POST or $_GET var.
|
by: dracolytch |
last post by:
Good day all,
Ok, I have a pretty tricky problem that I need some help with.
I pass around search query information a fair amount (specifically
WHERE statements). Normally, I just rawurlencode() the buggers, and
pass them via the URL. I like having the where clauses in the URL,
because then someone can just bookmark the URL, or send it to a friend,
and I don't have to worry about a thing.
If someone does a search that requires a LIKE...
|
by: Bung |
last post by:
Hi,
I have a tricky sql statment I have to write (tricky for me) and I am
stuck. I'm having trouble with the following problem.
Table1 (Column a, Column b, Column c)
Table2 (Column a, Column b, Column c)
Table3 (Column a, Column b, Column c)
Table1 contains a row of value (1, 2, 3)
|
by: Piotr Szukalski |
last post by:
Hi!
I have a quite tricky question about .NET debugger: do I need to install
the whole SDK to make SDK CLR debugger working?
The situation is as follows: I have an application deployed to 130
computers and everywhere it works just fine. Everywhere but two
machines... _important_ machines... I see there is no other way to sit by
the computers and investigate the issue. To do so I need a debugger - it's
enought if it can tell me where an...
|
by: PyPK |
last post by:
What possible tricky areas/questions could be asked in Python based
Technical Interviews?
| |
by: Danny |
last post by:
Hi there
I need help with a tricky problem.
I have a 2 dimensional array with qualities such as
ball size, ball color, ball weight.
Now I have to print out all the possible combinations of this.
assume I have it stored as such
i have two dimensional array ball:
|
by: Steve Jorgensen |
last post by:
== On Error Resume next, and Err.Number ==
If you want to call one of your procedures from another procedure, and check
for errors afterward, you mayimagine that you should write code something like
this...
On Error Resuse Next
MyFoo 123
lngErrNum = Err.Number
On Error Goto 0
|
by: pras.vaidya |
last post by:
Hi , below given question was asked to me during an interview and i
figured it out little tricky . It would be a great help if anyone
could solve it.
Code : -
main()
{
char *s1="abcd",*s2=NULL;
/* From here you call a function copy which has return type void .
|
by: NileshKorpe |
last post by:
Can you please send me link of some c++ tricky (confusing) questions
usually asked in the c++ technical interview.
Thank You
|
by: MorrganMail |
last post by:
Or at least I find it tricky. :-)
Assume we have three tables A, B and C. Table A contains a path and the
distance for traveling that path:
A (PathId, NodeId, Dist (from previous node))
1, 1, 0
1, 2, 10
1, 3, 5
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |