Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Bernd Oppolzer
__ From: IBM Mainframe Discussion List on behalf of Bernd Oppolzer Sent: Wednesday, June 21, 2017 2:04 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: PL/I and C (was Re: Simple (?) C question) Hi Frank, 1.) yes, the C area acquired by malloc must be freed by someone 2.) unfortunately,

Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Frank Swarbrick
regard. Frank From: IBM Mainframe Discussion List on behalf of Bernd Oppolzer Sent: Wednesday, June 21, 2017 2:04 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: PL/I and C (was Re: Simple (?) C question) Hi Frank, 1.) yes, the C area acquired by malloc must be freed by someone 2.) unfortunately

Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Bernd Oppolzer
viously NOT do this for str1ptr.) Side request... Could someone post the PL/I "JNI" copybook? Thanks, Frank From: Frank Swarbrick Sent: Tuesday, June 20, 2017 9:47 AM To: IBM Mainframe Discussion List Subject: Re: Simple (?) C question Thanks John. I

PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Frank Swarbrick
anks, Frank From: Frank Swarbrick Sent: Tuesday, June 20, 2017 9:47 AM To: IBM Mainframe Discussion List Subject: Re: Simple (?) C question Thanks John. I know of no code that does this, nor do I intend to implement any. What I was really trying to determine i

Re: Simple (?) C question

2017-06-20 Thread Paul Gilmartin
On Tue, 20 Jun 2017 16:37:56 -0700, retired mainframer wrote: >Does MacOS run on any IBM mainframe? >> No, but I've used setvbuf() that I mentioned later in this thread to accomplish this purpose on z/OS xlc. If xlc doesn't conform to POSIX it ought to be APARable: On Tue, 20 Jun 2017 09:44:02

Re: Simple (?) C question

2017-06-20 Thread retired mainframer
Does MacOS run on any IBM mainframe? > -Original Message- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On > Behalf Of Paul Gilmartin > Sent: Tuesday, June 20, 2017 7:44 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: Simple (?) C question &

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
Some additional remarks below ... Am 20.06.2017 um 22:56 schrieb Bernd Oppolzer: I tried the program, too, using my local Watcom C compiler. No problems, but I had to add some global definitions to make it run. Looks like this: #include #include #include char *get_static_string(void) {

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
regard. Thanks to everyone who answered. Frank From: IBM Mainframe Discussion List on behalf of John McKown Sent: Monday, June 19, 2017 7:59 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@o

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
It's thread safe in that sense that several processes (LE enclaves) running in parallel each get their own instance of the WSA, so there is no mixing of static variables in this case. Of course, if you use other variants of multi-threading which don't involve separate (that is, parallel) LE encla

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
Am 20.06.2017 um 13:12 schrieb Don Poitras: Not if you compile RENT. In that case the static is allocated in a separate area rather than being inside the load module. and: every invocation of the module from potentially parallel LE enclaves (for example, when used inside a DB2 stored proc envir

Re: Simple (?) C question

2017-06-20 Thread Anthony Giorgio
PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: I know there are at least a few C developers here, so I was wondering if you could answer a question. Is the following valid C? (I

Re: Simple (?) C question

2017-06-20 Thread Frank Swarbrick
cKown Sent: Monday, June 19, 2017 7:59 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: > I know there are at least a few C developers here, so I was wondering if > you could answe

Re: Simple (?) C question

2017-06-20 Thread Paul Gilmartin
On Mon, 19 Jun 2017 17:13:00 -0700, retired mainframer wrote: > >Probably unrelated to your real question but the format string passed to >printf should also have a \n after the %s to insure the output is visible. > On MacOS, at least, buffers are flushed when the program exits, so the output wil

Re: Simple (?) C question

2017-06-20 Thread David Crayford
That's not what I meant. It's not thread safe without locking. And even if you're not multi-threaded it may be better practice to copy the static C string into a buffer. Take strerror() for example. Once you've got the error you either print it immediately or copy the message into a buffer. str

Re: Simple (?) C question

2017-06-20 Thread Don Poitras
Not if you compile RENT. In that case the static is allocated in a separate area rather than being inside the load module. In article <32db4b0b-1271-18b1-574c-9cb6a37a2...@gmail.com> you wrote: > If the string can be mutated either by the client or the runtime > returning by reference is not re-e

Re: Simple (?) C question

2017-06-19 Thread David Crayford
If the string can be mutated either by the client or the runtime returning by reference is not re-entrant. I would always prefer to use strings buffers: int get_string(char * buf, size_t buflen); Strings are s much easier in C++. On 20/06/2017 9:59 AM, John McKown wrote: On Mon, Jun 19,

Re: Simple (?) C question

2017-06-19 Thread John McKown
On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: > I know there are at least a few C developers here, so I was wondering if > you could answer a question. Is the following valid C? (I'm not asking if > one should actually do it; only if its valid at all.) >

Re: Simple (?) C question

2017-06-19 Thread retired mainframer
t; Subject: Simple (?) C question > > I know there are at least a few C developers here, so I was wondering if you could answer a > question. Is the following valid C? (I'm not asking if one should actually do it; only if its > valid at all.) > char *get_static_string(void) {

Re: Simple (?) C question

2017-06-19 Thread Paul Gilmartin
On Mon, 19 Jun 2017 21:25:50 +, Frank Swarbrick wrote: >I know there are at least a few C developers here, so I was wondering if you >could answer a question. Is the following valid C? (I'm not asking if one >should actually do it; only if its valid at all.) >char *get_static_string(void)

Re: Simple (?) C question

2017-06-19 Thread Tom Brennan
Looks good to me. Like Peter says, the function returns the pointer correctly, and the compiler should put that string in a static memory location instead of on the stack. Now if you were to do something like this: char * x; printf("%s\n", get_static_string()); x = get_static_string();

Re: Simple (?) C question

2017-06-19 Thread Farley, Peter x23353
first array member. Peter -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Frank Swarbrick Sent: Monday, June 19, 2017 5:26 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Simple (?) C question I know there are at least a few C developers here,

Simple (?) C question

2017-06-19 Thread Frank Swarbrick
I know there are at least a few C developers here, so I was wondering if you could answer a question. Is the following valid C? (I'm not asking if one should actually do it; only if its valid at all.) char *get_static_string(void) { static char str[81] = "This is a statically allocated C st