Page 8 - Demo
P. 8
Interface to C/C++%uf09f%uf09fRCPConsult2023-2025Page 86.C/C++sourcefileThe C/C++sourcefilemust containat least one double export functionprepared by rules described above. In our example three export functions need to be definedin source file %u2018Stone_Circular.cpp%u2019for processing byselected compiler. The first we need to provide all required definitions for binding with STRUREL placed in an include file %u2018strurel.h%u2019.//* Include file with internal STRUREL definitions#include\Additionally, you may use diverse includes depending on your function code, like#include\The next block declares which functions will be manufactured as export namesextern\{//* Export functions definition for usage in STRURELDllExportdoubleStoneCircularVI(long*);DllExportdoubleStoneCircularGN(long*);DllExportdoubleStoneCircularFA(double,double,double,double,double,double,long*);}And finally, the code of three double functionsThe first one shows using of global vectorelementsdoubleStoneCircularVI(long*ier){/*Uses only vector notation to access values of Variables and Parameters.The sequence in input vector v_XP_ is predefined by Stochastic Model.*/*ier=0;returnv_XP_[3]*acos(-1.)/4*v_XP_[1]*pow(v_XP_[2],2)-v_XP_[4]*v_XP_[0];}Here elements containing values fromglobal vectorv_XP_can be accessed directly by an index, as is ordered in Stochastic Model of STRUREL.The corresponding definitions for handling withaglobal vectorare provided in an include file %u2018strurel.h%u2019. This file will be created automatically by STRUREL for each compilation of source file %u2018Stone_Circular.cpp%u2019and isamandatory objectfor usage of global vectors, global namesand information variables. Usually, it must be placed on topof the source text.The second function shows using of global namesdoubleStoneCircularGN(long*ier){/*Uses global names of Variables and Parameters to access their values.The sequence is arbitrary. Both STRUREL and C/C++ are case sensitive.*/*ier=0;returnPAR1*acos(-1.)/4*Strength*pow(Diameter,2)-PAR2*Load;}The third function shows usageof formal argumentsdoubleStoneCircularFA(doublel,doubles,doubled,doublep1,doublep2,doublepi,long*ier){/*Uses function argument values as defined in Symbolic Expressions.The sequence is predefined by definition of parameters of DEFFUNC.*/