Dropping the example code for RexxStart into a common C main:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rexx.h>
int main(int argc, char *argv[]) {
/* example code here */
}
and compiling with
gcc -D_GNU_SOURCE -I../include -std=c99 -pedantic rexxstart.c
leads to errors:
rexxstart.c: In function ‘main’:
rexxstart.c:8: error: ‘argv’ redeclared as different kind of symbol
rexxstart.c:6: note: previous definition of ‘argv’ was here
rexxstart.c:14: error: ‘macro_argument’ undeclared (first use in this function)
rexxstart.c:14: error: (Each undeclared identifier is reported only once
rexxstart.c:14: error: for each function it appears in.)
rexxstart.c:30: error: ‘retval’ undeclared (first use in this function)
The argv issue is easily fixed by changing the declaration of main(). macro_argument and retval are more difficult.
Here's a modified version of the example that compiles and runs:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rexx.h>
int main(int argc, char *argv[]) {
int return_code; /* interpreter return code */
short rc; /* converted return code */
CONSTRXSTRING argr[1]; /* rexx program argument string */
RXSTRING retstr; /* rexx program return value */
char return_buffer[250]; /* returned buffer */
char rexx_argument[] = "theargument";
/* build the argument string */
MAKERXSTRING(argr[0], rexx_argument, strlen(rexx_argument));
/* set up default return */
MAKERXSTRING(retstr, return_buffer, sizeof(return_buffer));
retstr.strptr[0] = 0;
return_code = RexxStart(1, // one argument
argr, // here it is
"./test.rex", // name of program
NULL, // use disk version
"bash", // default address name
RXCOMMAND, // called as a subcommand
NULL, // no exits
&rc, // where to put rc
&retstr); // where to put returned string
/* process return value */
printf("rc %i\n", rc);
if (retstr.strlength > 0) {
printf("ret: %s\n", retstr.strptr);
}
/* need to return storage? */
if (RXSTRPTR(retstr) != return_buffer) {
RexxFreeMemory(RXSTRPTR(retstr)); /* release the RXSTRING */
}
return 0;
}
Anonymous
Ticket moved from /p/oorexx/bugs/1136/
Can't be converted:
Used this ticket to test moving an item from one of our trackers to another. Bugs to documentation in this case.
Thanks for open this Geoff. We can't always get to these tickets as quickly as might be expected, but we appreciate people opening them.
Committed revision 8888. r[8888] docs trunk
Committed revision 8889. r[8889] docs 4.1 fixes branch
This documentation bug is fixed in the ooRexx 4.1.3 release.