473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

#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_Parms_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 CancelHandlerForReport( _CNL_Hndlr_Parms_T *cancel_info )
{
printf("In Cancel Handler for function 'Report' ...\n");
}
void CancelHandlerForMain( _CNL_Hndlr_Parms_T *cancel_info )
{
printf("In Cancel Handler for function 'main' ...\n");
}

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

Nov 7 '06 #1
8 2089
In article <11*********************@m73g2000cwd.googlegroups. 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*********************@m73g2000cwd.googlegroups. 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******@sympatico.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_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?
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_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?
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...FINALLY 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
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...
6
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
1
by: Gustavo L. Fabro | last post by:
Greetings! Going directly to the point: myclass.h: //-------------------------------------- #pragma managed //Forward declaration
11
by: ramu | last post by:
HI, Can anyone tell me about pragma? And can u give an example of how to use it?
15
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...
5
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...
26
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? ...
2
by: aleemakhtar1 | last post by:
wat is use of pragma directive in embedded sys ??
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.