473,769 Members | 3,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

#pragma cancel_handler

Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

http://publib.boulder.ibm.com/infoce.../cpprog436.htm

What #pragma cancel_handler does is provide the building blocks for try
.... finally code block in a C function.

I am researching the degree of difficulty involved in porting ILE C
code from an IBM AS400 to GNU C.

thanks,

-Steve

FTA:

Cancel handlers provide an important function by allowing you to get
control for clean-up and recovery actions when call stack entries are
ended by something other than a normal return.

On the #pragma cancel_handler directive, the name of the cancel handler
routine (a bound ILE procedure) is specified, along with a user-defined
communications area. It is through the communications area that
information is passed from the application to the handler function.
When the cancel handler function is called, it is passed a pointer to a
structure of type _CNL_Hndlr_Parm s_T which is defined in the <except.h>
header file. This structure contains a pointer to the communications
area in addition to some other useful information that is passed by the
system. This additional information includes the reason why the call
was cancelled.

void CancelHandlerFo rReport( _CNL_Hndlr_Parm s_T *cancel_info )
{
printf("In Cancel Handler for function 'Report' ...\n");
}
void CancelHandlerFo rMain( _CNL_Hndlr_Parm s_T *cancel_info )
{
printf("In Cancel Handler for function 'main' ...\n");
}

int main( void )
{
volatile unsigned return_code; /* communications area */
#pragma cancel_handler( CancelHandlerFo rMain, return_code )
return_code = 0;
#pragma disable_handler
}

Nov 7 '06 #1
8 2107
In article <11************ *********@m73g2 000cwd.googlegr oups.com>,
Steve Richter <St************ @gmail.comwrote :
>Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?
No ANSI/ISO C equivilent; for GNU C, you'd need to ask in a gnu
newgroup.
--
Prototypes are supertypes of their clones. -- maplesoft
Nov 7 '06 #2

Walter Roberson wrote:
In article <11************ *********@m73g2 000cwd.googlegr oups.com>,
Steve Richter <St************ @gmail.comwrote :
Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

No ANSI/ISO C equivilent; for GNU C, you'd need to ask in a gnu
newgroup.
ok, thanks

Nov 7 '06 #3

Steve Richter wrote:
Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

http://publib.boulder.ibm.com/infoce.../cpprog436.htm
FWIW, according to the above link, a cancel_handler is a C++ feature.

Since this is comp.lang.C, we don't know about or discuss C++ features.
There certainly won't be an ANSI C equivalent to the #pragma
cancel_handler in ILE C, because that feature is not part of the C
language at all.

When you talk to the GNU C groups, please address your question to the
C++ side of the fence.

Thanks

What #pragma cancel_handler does is provide the building blocks for try
... finally code block in a C function.
Apparently, it doesn't, since there is no such thing as a "try ...
finally" code block in C. As I said before, you want C++, not C

Nov 7 '06 #4
"Lew Pitcher" <lp******@sympa tico.cawrites:
Steve Richter wrote:
>What #pragma cancel_handler does is provide the building blocks for try
... finally code block in a C function.

Apparently, it doesn't, since there is no such thing as a "try ...
finally" code block in C. As I said before, you want C++, not C
I think he wants to implement try...finally in C, actually.
--
"The fact that there is a holy war doesn't mean that one of the sides
doesn't suck - usually both do..."
--Alexander Viro
Nov 7 '06 #5

Lew Pitcher wrote:
Steve Richter wrote:
Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

http://publib.boulder.ibm.com/infoce.../cpprog436.htm

FWIW, according to the above link, a cancel_handler is a C++ feature.

Since this is comp.lang.C, we don't know about or discuss C++ features.
There certainly won't be an ANSI C equivalent to the #pragma
cancel_handler in ILE C, because that feature is not part of the C
language at all.
yeah, it does say that but I have used it in ILE C and it works as
documented. I dont follow. How does ANSI C handle exceptions? I am
reading about signal handlers in the Linux books I have but none of
them seem to deal with how to implement a try .... finally block.

-Steve

Nov 7 '06 #6
Cla
Steve Richter wrote:
Lew Pitcher wrote:
>>Steve Richter wrote:
>>>Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

http://publib.boulder.ibm.com/infoce.../cpprog436.htm

FWIW, according to the above link, a cancel_handler is a C++ feature.

Since this is comp.lang.C, we don't know about or discuss C++ features.
There certainly won't be an ANSI C equivalent to the #pragma
cancel_handle r in ILE C, because that feature is not part of the C
language at all.


yeah, it does say that but I have used it in ILE C and it works as
documented. I dont follow. How does ANSI C handle exceptions?
There are no such things, so you don't handle them at all.
I am reading about signal handlers in the Linux books I have but none of
them seem to deal with how to implement a try .... finally block.

-Steve
I know what signal handlers are, but I cannot recall anything about a
'try .... finally block'.

Nov 7 '06 #7


Steve Richter wrote On 11/07/06 14:51,:
Lew Pitcher wrote:
>>Steve Richter wrote:
>>>Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?

http://publib.boulder.ibm.com/infoce.../cpprog436.htm

FWIW, according to the above link, a cancel_handler is a C++ feature.

Since this is comp.lang.C, we don't know about or discuss C++ features.
There certainly won't be an ANSI C equivalent to the #pragma
cancel_handle r in ILE C, because that feature is not part of the C
language at all.


yeah, it does say that but I have used it in ILE C and it works as
documented. I dont follow. How does ANSI C handle exceptions?
The same way a fish rides a bicycle.

There are no exceptions in C, hence no handling.
I am
reading about signal handlers in the Linux books I have but none of
them seem to deal with how to implement a try .... finally block.
Not surprising: C has no "try ... finally block," and signals
are not exceptions.

As others have pointed out, you are addressing your question
to the wrong newsgroup. You are asking cooks about calculus, or
mathematicians about marzipan. You may get some answers, but if
I were you I wouldn't pay them much attention -- find a forum
where the people actually know something about your topic and
won't just make wild guesses.

That forum might be comp.lang.c++, as your repeated references
to try/finally suggest you may be writing in that language (maybe
without knowing it). Or if cancel_handler is not a C++ feature
but an IBM-specific extension, maybe you should look for a forum
devoted to IBM-specific topics. If this cancel_handler thing is
as useful and pervasive as you imply, you cannot be the first
person who's tried to find a substitute for it.

But whatever it may be, it's not C.

--
Er*********@sun .com

Nov 7 '06 #8
Hi Steve,
yeah, it does say that but I have used it in ILE C and it works as
documented. I dont follow. How does ANSI C handle exceptions? I am
reading about signal handlers in the Linux books I have but none of
them seem to deal with how to implement a try .... finally block.
Exception is a compiler construct that allows you to perform non local
jump with the appropriate stack unwinding. There is no exception in
ANSI C (but your compiler may have some specific extension to support
exception).

You can implement the TRY...CATCH...F INALLY construct in C, but it is
really awkward (remember seeing that in the DCE/RPC package on Linux.
It is based on sigsetjmp/siglongjmp). You can get something close to
what you want, but not exactly what you can achieve at compiler level.

Cheers,
Loic

Nov 7 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2665
by: Steven T. Hatton | last post by:
Stroustrup says this: http://www.research.att.com/~bs/bs_faq2.html#macro "So, what's wrong with using macros?" "And yes, I do know that there are things known as macros that doesn't suffer the problems of C/C++ preprocessor macros. However, I have no
6
3968
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
1
3085
by: Gustavo L. Fabro | last post by:
Greetings! Going directly to the point: myclass.h: //-------------------------------------- #pragma managed //Forward declaration
11
2870
by: ramu | last post by:
HI, Can anyone tell me about pragma? And can u give an example of how to use it?
15
3761
by: muttaa | last post by:
Hello all, I'm a beginner in C...May i like to know the difference between a #pragma and a #define.... Also,yet i'm unclear what a pragma is all about as i can find topics on it only in high-standard books...
5
3608
by: venkat | last post by:
Hi, I have come across the a pragma definition " #pragma switch direct ". I don't know any thing about pragma's. Even i when i search through google not getting exact information. what does pragma does?. what the statment "#pragma switch direct" does?. Thanks, Venkat.
26
3825
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? Thanks...
2
3921
by: aleemakhtar1 | last post by:
wat is use of pragma directive in embedded sys ??
0
10695
debasisdas
by: debasisdas | last post by:
PRAGMA:-Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler. A pragma is an instruction to the Oracle compiler that tells it to do something. In this case you are telling Oracle to associate an error that you choose to a variable that you choose. This pragma must go in the declarative section of your block. Types of PRAGMA...
0
10206
Oralloy
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...
0
9851
tracyyun
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...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.