Examples for Open C Libraries |
This example shows how to handle a global variable within the library code and provides a solution to the WSD problem.
The MMP file for Handle Global Var is as shown below:
TARGET globalvarex.exe TARGETTYPE exe UID 0 0xA000131E CAPABILITY NONE VENDORID 0 SOURCEPATH . .\data START RESOURCE globalvarex_reg.rss #ifdef WINSCW TARGETPATH \private\10003a3f\apps #else TARGETPATH \private\10003a3f\import\apps #endif END //RESOURCE SOURCEPATH ..\src SOURCE globalvarex.c USERINCLUDE ..\inc USERINCLUDE ..\libwsddll\inc SYSTEMINCLUDE \epoc32\include SYSTEMINCLUDE \epoc32\include\stdapis STATICLIBRARY libcrt0.lib LIBRARY libc.lib LIBRARY libpthread.lib LIBRARY libwsddll.lib LIBRARY euser.lib
The code snippet shows how to handle a global variable from within the library and also, provides a solution to the WSD problem.
//systeminclude #include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<error.h> #include "wsddll.h" //#include<staticlibinit_gcce.h> int main(void) { char str[20]; printf ("DLL global int value : %d\n",GetDllInt()); GetDllString(str); printf ("DLL global String value : %s\n",str); SetDllInt(1008); SetDllString("HelloWorld"); printf ("DLL global int value : %d\n",GetDllInt()); GetDllString(str); printf ("DLL global String value : %s\n",str); printf("Press any key to exit.\n"); getchar(); return 0; }
NOTE: This code has been tested on Carbide.
ŠNokia 2007 |