I don't seem to be able to declare a D variable in C++. I am coding the parameter to printf() as
*reinterpret_cast<D(31,0)*>(value) where value is declared as char[1] and contains (variable length, passed to me as a parameter) the fixed point decimal data. The compiler is giving me line 1047.39: CCN5130 (S) "D" is not declared. (And yes, I #include <decimal.h> without error.) I am starting to think this approach is hopeless (pending what if anything I hear from Toronto). I am currently using an interpretive loop to format the decimal data. I am going to look into using __EDMK() instead. (And yes, the volume, potentially millions of iterations per day, justifies the effort.) Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David W Noon Sent: Wednesday, April 26, 2017 8:24 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Can XLC printf() take "%D(*,*)"? On Tue, 25 Apr 2017 16:07:38 -0700, Charles Mills (charl...@mcn.org) wrote about "Re: Can XLC printf() take "%D(*,*)"?" (in <0c5901d2be18$bc7c4900$3574db00$@mcn.org>): [snip] > But I consistently get 'D(*,*' for output. Here is my exact format: > "%*.*D(*,*)" and I am calling it with 20, 5, &decimal_number, > precision, scale. (I started out with 20, 5 like in the example just > to make my life > easier.) Your parameter sequence is wrong. You need to pass: field width, by value decimal places, by value digitsof(x), by value precisionof(x), by value x, by value in that order. You should not be passing a pointer (&x); everything is passed by value. > Here's a rub. The code is C++ and fixed point decimal support is > limited to C ... but ... at the Spring TDM I asked a guy from Toronto > why the heck the fixed point decimal support is only C and not C++. He > told me -- very interesting story but I am going to play it safe here > and assume it is under NDA. But he did tell me that I could call > printf() from C++ and format fixed point decimal with no issues as printf() is a C function, not C++. I'm not sure what "limited to C" means in a C++ context. After all, C is largely a subset of C++, albeit with a few wrinkles these days. I could understand that STL has no piping operator or I/O manipulators for packed decimal, but the manipulation of packed decimal values in general code should really be the same for C and C++. However, I did not write the IBM compiler(s), so I don't know how much code the C and C++ compilers share. > I had not added decimal.h to my code as there is no packed logic other > than the printf() (data comes in from an external source). I added the > #include but still no joy. How are you declaring the decimal variables? -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* david.w.n...@googlemail.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN