How to make variable values persistent between function calls in c / c++ -


i have following szenario. calling functions in dll ibm notes application (lotusscript).

one of functions uses type structures , encounter problems on 64bit. values in type can passed function byref, need pass values byval.

so decided have single arguments in function header every value. far, good. have around 43 arguments, ls can handle 31 ...

next idea call i.e init_reg_person_info(arg1,arg2, ... ) before make call function registers new user.

init_reg_person_info(arg1,arg2, ... ); init_reg_id_info(arg1,arg2, ... ); register_user(); 

in c, have function ( know, 1 argument, testing )

    /*====================================================================================*/     /* function: bcc_initregpersoninfo                                                    */     /*====================================================================================*/     status lnpublic bcc_initregpersoninfo(char *firstname){         try {             //extern char *reg_person_info_firstname;             memset(&reg_person_info, 0, sizeof (reg_person_info));             reg_person_info.firstname = firstname;              return noerror;          } catch (...)    {             logeventtext("* bcc_initregpersoninfo::exception *", nullhandle, noerror);             return 1;         }     } 

whre reg_person_info declared global variable

reg_person_info reg_person_info; 

later, in register_user(), try access value global variable

logeventtext("* bcc_regnewperson1():reg_person_info.firstname = %s", nullhandle, noerror,                     reg_person_info.firstname); 

but value empty. assume, variable deleted / reset, exit init_reg_person_info(arg1,arg2, ... );

how make value persistent between function calls?

you need create external linkage reg_person_info structure. in way implicitly saying "i want available units declares it, including main declaration unit".

in begininning of file have:

status lnpublic bcc_initregpersoninfo(char *firstname){...} 

simply put extern typeofreg_person_info reg_person_info;

by looks of code snippet, assuming have declared reg_person_info somewhere in header file , #include header file need? i'll update answer once have seen more code in question.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -