To build a simple C DLL, write code using the #pragma export directive to export specific external functions and variables as shown in Figure 1.
#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.