fetchable assembler program with OS linkage

Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

fetchable assembler program with OS linkage

Postby Pedro » Thu Jul 07, 2016 6:03 am

How to do?

When I try
#pragma linkage(TEST3,OS,fetchable)    

I get:
WARNING CBC3508 PEDRO.MISC.SOURCE(TEST2):7                
Option os fetchable for #pragma linkage is not supported.  

But is there some trick to avoid binding the parts together into a composite load module?
Pedro Vera
User avatar
Posts: 565
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 38 times

Re: fetchable assembler program with OS linkage


Re: fetchable assembler program with OS linkage

Postby steve-myers » Wed Jul 13, 2016 11:22 am

I have been thinking about this for almost a week, and concluded - sorry - this is BS.

First, I could not decide if you are trying to use the pragma to define a program that is callable from JCL or it is calling a program using the JCL interface.

Case 1 -- you don't need the progma -

int mypgm(int argn, char **argc) ...

Look familar? The library pre parses the PARM text as though it was on a command line.

// EXEC PGM=thepgm,PARM='A B C'

argn = 4, argc[ 1 ] = A, and so on. I forget what argc[ 0 ] is set to, but it is set

Case 2. Now I don't do much mainframe C, but

struct osparm
  int len; // I don't know, off hand, how to define a 16 bit int, but that's what you want
  char text[100];

int routine( struct osparm);

Note: again, no pragma. What you need is already in the language.
Global moderator
Posts: 1863
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 190 times

Re: fetchable assembler program with OS linkage

Postby mwilliams » Fri Mar 03, 2017 10:17 pm

I am a bit confused as to what we are trying to accomplish?
Is the intent to have a C program load and call an assembler program?
Or call an assembler sub-module from a C program which is statically linked in the composite load module.

The first problem is with the “#pragma linkage” options.
According to the z/OS C/C++ language manual, specifies only 2 parms – the identifier and the option.
As my understanding, a C program can only load & call Language Environment (LE) compliant executable module. In other words, C program does not directly support dynamically calling an assembler (none LE compliant) module.

Second, the context of “fetchable” is miss-leading in the linkage options. For example, based upon the description of “fetch” (function to get a load module) in the C/C++ run time reference manual, explains the proper use of the “fetchable” linkage parameter. Basically, for example if you have two standalone C programs, in which program “A” loads/executes program “B”, the source of program “B” contains linkage (progB, fetchable). Where progB is the function name that is designated as the entry point of load module associated with program B. However, as for program A, pragma linkage (identifier, OS) just specifies the standard “OS” calling convention.

Bottom line, if you need to call an assembler module which is statically linked in your “composite load module”, just specify “#pragma linkage(TEST3,OS)”.
However, it highly recommended that the “C” should call LE compliant modules.

But if you need to dynamically call an assembler from a C program, that’s totally different animal. Basically, that involves stubbing in a LE compliant assembler module which dynamically loads and executes a non-LE compliant (legacy) assembler module(s).
Posts: 11
Joined: Thu Feb 07, 2013 8:55 am
Has thanked: 0 time
Been thanked: 1 time

Return to C, C++


  • Related topics
    Last post