#197 Doc: Rexx PG 10.3.3.3 Example: example does not compile

4.1.3
closed
fixed (2)
1
2013-07-09
2012-10-24
No

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;
}   

Discussion

  • Mark Miesfeld

    Mark Miesfeld - 2013-01-23

    Ticket moved from /p/oorexx/bugs/1136/

    Can't be converted:

    • _pending_work_items: none
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-23

    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.

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-23
    • assigned_to: Mark Miesfeld
    • milestone: None --> 4.1.2
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-24
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-24

    Committed revision 8888. r[8888] docs trunk
    Committed revision 8889. r[8889] docs 4.1 fixes branch

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-24
    • labels: --> fixed
    • status: open --> pending
    • milestone: 4.1.2 --> Next_Release
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-01-31
    • milestone: Next_Release --> 4.1.3
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-07-09
    • status: pending --> closed
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-07-09

    This documentation bug is fixed in the ooRexx 4.1.3 release.

     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks