Hello everybody. I have a C++ program calling a function from a service program that is written in RPG. The function has the following prototype:
I made a prototype in C ++ as follows:
The call to this function is done like this:
The problem is that under some conditions the CFTGetDmn function is called as if more than 1 parameter was passed to it: in the debugger you can see that %parms is greater than 1. I tried to make a case where the error would be reproduced, but I failed : everything works correctly. And only in the big program does some terrible magic happen.
I said this error is reproducible only under certain conditions. This means that if you change the code of the function where the call to CFTGetDmn occurs, for example, change str after initialization, then the magic disappears.
Can someone explain what is happening?
Code:
PCFTGetDmn B export DCFTGetDmn pi 10 D UsId 10A const D BDate 7P 0 options (*nopass) D RB 10A options (*nopass)
Code:
struct Char10 {
char arr[10];
};
extern "RPG" Char10 CFTGetDmn (const char *);
Code:
std::string str = "ABCDEFGHIJ"; Char10 res = CFTGetDmn (str.c_str());
I said this error is reproducible only under certain conditions. This means that if you change the code of the function where the call to CFTGetDmn occurs, for example, change str after initialization, then the magic disappears.
Can someone explain what is happening?




Comment