Page 5 - Demo
P. 5


                                    Interface to C/C++%uf09f%uf09fRCPConsult2023-2025Page 54.Interaction between STRURELand C/C++Amajor partof communication with theC/C++Interface is usage of sourcefileswith extension %u2019.c%u2019for a C languageor with extension %u2019.cpp%u2019. for a C++ language.With the classic computer language such as C/C++the creation of Add-on is more complex as compared to usage of external engines like PYTHONor others. You need source file compiler, librarian, resource file compiler and linker to create a customized Windows DLL. Using specialrules for creation of resource file suchaC/C++based DLL can be built directly. Then, it will be accepted as so called Buildout Add-onand connected withSTRUREL.The integration of Buildout Add-onin STRUREL is provided by using theDEFFUNC keyword inSymboliclanguage.The syntax of DEFFUNC forinteraction with sucha C/C++basedAdd-on is:DEFFUNC(i, k |l, SAONAME)(PARAMETERLIST){COMMENT}=FUNNAME%uf046i: ID of the user defined function in SymbolicInterpreter%uf046k: kind of Add-on as number: 2%u2013C/C++or%uf046l: language as text: C, CPP%uf046SAONAME: name of the Add-on (without extension .sao)%uf046PARAMETERLIST: lists the parameters the function expects. The names given are arbitrary. The parameter list can be empty or have maximal 16 members.%uf046COMMENT: some comment (may be omitted)%uf046FUNNAME: the name of the export function to callThe user definedfunction with argumentscan be expressed in the Symboliclanguage of STRUREL as shown below. DEFFUNC(1,2,CppSAO,\{Uses function arguments}=CppFunctionorDEFFUNC(1,CPP,CppSAO,\{Uses function arguments}=CppFunctionIf you wish to create an Add-on using g++, c++or clyou may prepare a C++source file%u2018CppSource.cpp%u2019with definition of anexport functionlike//* Include file with internal STRUREL definitions#include\extern\{//* Export function definition for usage in STRURELDllExportdoubleCppFunction(double,double,double,double,long*);}doubleCppFunction(doublea,doubleb,doublec,doubled,long*ier){/*Uses function argument values as defined in Symbolic Expressions.The sequence is predefined by definition of parameters of DEFFUNC.*/*ier=0;returna*b/4*c-d;}
                                
   1   2   3   4   5   6   7   8   9   10