z/OS Language Environment Programming Guide for 64-bit Virtual Addressing Mode
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Writing your C DLL code

z/OS Language Environment Programming Guide for 64-bit Virtual Addressing Mode
SA38-0689-00

To build a C DLL, write code using the #pragma export directive to export specific external functions and variables as shown in Figure 1.

Figure 1. Using #pragma export to create a DLL executable module named BASICIO
   #pragma export(bopen)
   #pragma export(bclose)
   #pragma export(bread)
   #pragma export(bwrite)
   int bopen(const char* file, const char* mode) {
     ...
   }
   int bclose(int) {
     ...
   }
   int bread(int bytes) {
     ...
   }
   int bwrite(int bytes) {
     ...
   }
   #pragma export(berror)
   int berror;
   char buffer[1024];
     ...
   

For the previous example, the functions bopen(), bclose(), bread(), and bwrite() are exported; the variable berror is exported; and the variable buffer is not exported.

Note: To export all defined functions and variables with external linkage in the compilation unit to the users of the DLL, compile with the EXPORTALL compile option. All defined functions and variables with external linkage will be accessible from this DLL and by all users of this DLL. However, exporting all functions and variables has a performance penalty, especially when compiling with the C/C++ IPA option. When you use EXPORTALL you do not need to include #pragma export in your code.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014