IBM Z and LinuxONE Languages

Languages

Languages

Broad range of supported development languages and tools allows to transform software delivery practices.

 View Only
Expand all | Collapse all

XL C (Metal) - At compile time is there a system built-in, macro, or function that can be used to obtain the CSECT?

  • 1.  XL C (Metal) - At compile time is there a system built-in, macro, or function that can be used to obtain the CSECT?

    Posted Tue July 06, 2021 10:01 PM
    Hello,

    I'm writing some library routines that will live in .h files and want to be able to obtain the name of the CSECT that their code will be residing in -- at compile time.

    For example, I'm pretty sure I could do something like this:

    #define theCsect "MYCSECT"
    ...
    printf("theCsect detected an issue...");
    ​

    which should resolve to:

    printf("MYCSECT detected an issue...");​
    And then make sure that theCsect is always  #defined in every module.

    In assembler there is the built in variable &SYSSECT, which is set to the CSECT name specified in the assembly.  In Metal C, I can
    #pragma map(main,MYCSECT)​
    ​​​So what I'm looking for is some sort of compile time function/built-in/system variable/system macro/whatever that could be used in lieu of the #define technique above, perhaps similar to the __function__ macro (which will return the name of the current function being compiled, not the enclosing CSECT.

    Thanks,
    Scott​


  • 2.  RE: XL C (Metal) - At compile time is there a system built-in, macro, or function that can be used to obtain the CSECT?

    Posted Fri July 09, 2021 01:34 PM
    Hi Scott,

    Unfortunately, we do not know of a way to do this. You can use the #pragma csect directive to name your csect, but that is a "set" operation, not a "get" operation.

    Others following this topic group please feel free to chime in.




    ------------------------------
    Linda Chui
    Compilation Technology & Enterprise Products
    IBM Canada
    ------------------------------