×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On 27/10/2009, at 2:42 AM, Barbara Morris wrote:
Scott explained how *CNOWIDEN controls more than just widening.
Not described in the RPG reference material as far as I can see. Just
a vague imprecation to use *CWIDEN or *CNOWIDEN when communicating
with C but little about its actual effect.
It also
controls whether the 1-byte return value is treated as an aggregate
(character string) or as a scalar (integer).
My understanding is that aggregates are data structures and arrays
(including multi-byte fixed-length character types) and scalar is
everything else (1-byte char, short, int, long long, pointers of all
types). The distinction being whether the variable can hold multiple
values at the same time. A numeric variable of any type can hold only
one value therefore scalar. A pointer can hold only one address
therefore scalar. A 1-byte char can hold only a single character
therefore scalar. Structures and arrays can hold multiple different
values and types. It seems the idea that a scalar is also numeric is
yet another C peculiarity--much like its weird view that char is a
number.
You are correct that when a C function returns char and the RPG
prototype is defined without any special EXTPROC value, then the RPG
prototype would have to define the return value as a 1-byte unsigned
integer, and then the caller would have to convert the returned
value to
a 1-byte char.
By the way, you can write a C function to return a 1-byte aggregate by
defining the return value as a struct with a 1-byte subfield.
Thanks, I might use this method because it will allow me to keep all
the changes in the same language and source module. It might confuse
the C weenies but they won't have to look at it or use it and it will
be transparent to RPG and COBOL consumers.
Also by the way, starting in V6R1, this difference regarding single-
byte
return values disappears. Aggregate return values up to 16 bytes get
handled by the system in the same way as scalar return values.
True but doesn't that require recompiling of both caller and callee to
get the new behaviour? I recall some previous discussion on this for
CL (adds archive search to list of things to do today).
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.