Thread View: comp.protocols.ibm
2 messages
2 total messages
Started by Pam Williams
Mon, 06 May 1991 18:26
Passing by Reference in CPI-C
Author: Pam Williams
Date: Mon, 06 May 1991 18:26
Date: Mon, 06 May 1991 18:26
47 lines
1420 bytes
1420 bytes
Can anyone tell me the type for parameters to CPI-C calls in 'C'. Specifically,
when passing integer values to a call.
For example, the SAA CPI-C Manual specifies:
Set_Deallocate_Type:
cmdsdt( conv_id, deallocate_type, return_code)
conv_id (input)
deallocate_type(input)
return_code(output)
And the C Pseudonym File specifies:
CM_ENTRY cmsdt (unsigned char CM_PTR, CM_INT32 CM_PTR, CM_INT32 CM_PTR)
where CM_ENTRY is extern void
and CM_PTR is *.
I assume my call should then be for example:
u_char *conv_id;
int dealloc_type = CM_DEALLOCATE_CONFIRM;
int rc;
cmsdt ( conv_id, &dealloc_type, &rc);
Bottom Line: Is my logic correct in that pointers are required?
If so, Why was it designed to require passing the address for integer parameters.
It seems much more obvious to do: cmsdt (conv_id, CM_DEALLOCATE_CONFIRM, &rc);
Thanks for the advice,
Pam Williams
Hewlett-Packard Co
pjw@cup.hp.com
Re: Passing by Reference in CPI-C
Author: Pam Williams
Date: Wed, 15 May 1991 17:01
Date: Wed, 15 May 1991 17:01
26 lines
1377 bytes
1377 bytes
Following is a reply I received -- pjw I'm replying to your question in the protocols.ibm (?) newsgroup about why you need to pass a pointer to an input only integer in CPI-C. The reason behind this is that the CPI-C interface was intended to be the same from all languages. The CPI-C implementation code would not have to know from which language a call came from. So, for some languages which only support call by reference (do Fortran or COBOL fall in this category? are there any?) CPI-C requires everything to be passed as a pointer (C's version of call by reference). I'll admit that for C, this is very counter-intuitive and can end up being downright ugly coding style. Feel free to post this to the newsgroup if you would like. By the way, do anyone contact you about CPI-C test cases? Peter J. Schwaller APPC Market Enablement IBM Corp. As usual, my opinions are my own and not necessarily shared by my employer.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads