× 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.



OK Bruce - so today I pick YOU as my picker of nits!!

C U in Orlando, I hope - and will I be able to get that Dr Pepper you owe me?

Cheers
Vern

Bruce Vining wrote:
I'm confused. With C, when calling a function, all argument
(parameter) passing is is by value. That's how C is defined. By convention
many functions may pass by value a pointer to the struct, and with arrays it
gets a little muddy as an array is really a pointer to the first element
(though the pointer again is passed by value), but that's an implementation
decision of the function provider, not C.

So what's wrong with "C-structs are passed that way"? For it not to
be passed "that way" (by value) you need to change what you're passing --
namely to a pointer to the struct. In which case you aren't passing the
struct anyway...

Bruce (perhaps being just a tad nitpicky this morning, and I'm sure some may
think a lot more than "perhaps" lol)

On Thu, Feb 4, 2010 at 4:57 PM, Vern Hamberg <vhamberg@xxxxxxxxxxx> wrote:

Yeah, Scott - I over- and erroneously stated the matter of passing
structs. I was actually a little surprised that it was passed by value
here. I believe this is not just an IBM i function, so who knows the
history?

And I so agree that going to the docs first is absolutely necessary. The
proverbial butt will thank you forever!!

My post was a bit of a stream-of-consciousness thing, by the way - was
relating what I was finding as I wrote!! So I guessed on the meaning of
iconv_t, then went and looked it up. Hope that wasn't too confusing!! It
was early here!

Vern

Scott Klement wrote:
Hi Vern,


I suspect the first parameter is an integer but I don't know for sure -
it's called a conversion descriptor and in the docs has a data type of
iconv_t, so I'd have to go to the QSYSINC/H source file to find what
that is.

in RPG the first parameter should look like this (for those of you who
are too lazy to search for examples)

d iconv_t DS qualified
d based(Template)
d return_value 10I 0
d cd 10I 0 dim(12)



Well, it turns out to be a struct - comprising 1 integer and an array of
12 integers. This has to be by VALUE, because C-structs are passed that
way.
It's true that this API expects the structure to be passed by value.
However, it's *not* because "C-structs are passed that way". The vast
majority of structures I've seen used in C are passed by reference.

This one just /happens/ to be passed by value.

Just do what the API is expecting. No need for trial and error, or
doing things wrong just because you have some preconceived notion of how
it should work. Just do what it wants you to do. It'll save you years
of headaches.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.