|
Date: Thu, 31 May 2001 09:27:11 -0400 From: "Slava Zharichenko" <Slava.Zharichenko@exel.com> Subject: Please read: Pointer not set for location ..... > ... >and change return variable definition from 1 *char to 16 *char even RPG >procedure returns only 1 *char. > >Now it works , first byte contain return value and other 15 some none >displayable characters. > >Can anybody explain it? Slava, you should be sure to use %sst in your CL, so you only use the first byte of the returned value. By the way, you don't need to define it as 16 bytes; you just need more than 1. What's happening is that RPG and CL disagree on how to handle 1 byte return values. CL and C handle them one way; RPG and COBOL handle them another (CL and C are "right" because they were first, but RPG and COBOL can't change because of all the existing programs that expect it to be done "the RPG way"). What's actually happening is that C and CL think of 1A (at least in return values) as a 1-byte unsigned integer, while RPG and COBOL think of it as a 1-byte structure (string); unfortunately, structures are returned using a sort of pointer mechanism under the covers. In V5R1, you can code a special first parameter for EXTPROC to avoid this problem. D rpgproc pr 1a EXTPROC(*CL : 'RPGPROC') D calledByC pr 1a EXTPROC(*CWIDEN : 'calledByC') Use *CL when you're called by CL; use *CWIDEN (or *CNOWIDEN if the C is not widening parameters) when calling C or being called by C. *CWIDEN avoids problems with several parameter types passed by value (char(1a), short (5i 0), unsigned short (5u 0), float(4f), wchar (1C or 1G)). Barbara Morris +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
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.