⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usedl2.c

📁 This package consists of the executable (UCW), a default script file, this file, and the library fi
💻 C
字号:
/* usedl2.c
 * This second example uses uc_compile_fn() to generate
 * C-calleable function wrappers around UC expressions.
 * Note that the resulting functions use the __stdcall calling
 * convention, which makes it possible for this code to work
 * with other languages.
 */
#include <stdio.h>
#include <math.h>
#include "ucdl.h"

// note where __stdcall goes...
typedef double (__stdcall *DFN)(double);   
typedef int (__stdcall *IFN)(int,int);

int main()
{
 double res, maxdiff = 0.0;
 DFN pf;
 IFN pfi;
 int i;
 uc_init(NULL,0);
 pf = uc_compile_fn("double x","x*x");
 for(i = 0; i < 1000; i++) {
   res = fabs(pf(2.0)-4.0);
   if (res > maxdiff) maxdiff = res;
 } 
 printf("max diff was %lf\n",maxdiff);
 pfi = uc_compile_fn("int x, int y","x - y");
 printf("next call was %d\n",pfi(20,13));
 uc_finis();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -