python中嵌入C语言脚本Word文档格式.docx

上传人:b****5 文档编号:16699869 上传时间:2022-11-25 格式:DOCX 页数:7 大小:25.56KB
下载 相关 举报
python中嵌入C语言脚本Word文档格式.docx_第1页
第1页 / 共7页
python中嵌入C语言脚本Word文档格式.docx_第2页
第2页 / 共7页
python中嵌入C语言脚本Word文档格式.docx_第3页
第3页 / 共7页
python中嵌入C语言脚本Word文档格式.docx_第4页
第4页 / 共7页
python中嵌入C语言脚本Word文档格式.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

python中嵌入C语言脚本Word文档格式.docx

《python中嵌入C语言脚本Word文档格式.docx》由会员分享,可在线阅读,更多相关《python中嵌入C语言脚本Word文档格式.docx(7页珍藏版)》请在冰豆网上搜索。

python中嵌入C语言脚本Word文档格式.docx

解释执行

6.813

FreeBASIC

fbc0.16b

编译的可执行文件(-arch486)

8.022

编译的可执行文件(-arch686)

7.619

forth

4th3.5a2

4thcxfib.4th

277

这个表现太失望了

4thcsvfib.4thfib.hx

4thlxfib.hx

196

4thlgfib.hxfib.c

mingw-O2fib.c-ofib.exe

110

gforth-0.6.2

Gforth-fastfib.gfth

14.719

不错,不过不是说和C的速度可以比嘛?

怎么也就是优化的python的速度啊

 

注:

其余源程序

freebasicfunctionfib(xasinteger)asinteger

ifx&

lt;

=1then

return1

else

returnfib(x-1)+fib(x-2)

endif

endfunctiondimstarttime,endtimeasdouble

dimresasintegerstarttime=timer

res=fib(40)

endtime=timer

print"

fib(40)="

;

res

timeelapsed:

"

(endtime-starttime);

s"

4th :

fib(x--y)

dup2&

gt;

if

dup1-recurse

swap2-recurse+

exit

then

drop1;

time41fib.crtime

swap-

."

timeelapsed"

.."

cr

gforth-0.6.2:

fib(x--y)

if

dup1-recurse

swap2-recurse+

exit

then

utime41fib.crutime

2swapd-

d.."

us"

如果在windows下使用mingw编译当前的TinyCC,嵌入C脚本会报错:

tcc:

file'

/c/ProgramFiles/tcc/libtcc1.a'

notfound

DougCurrie在tcc的邮件列表里面提供了一个补丁:

HereiswhatIdid(andreportedtothemailinglist)lastFebruary,

sothepatchmaynotbeaccurateformorerecentversions,butthe

issuesarethesame...

Ihavebeenabletocreatealibtcc.dllforWinXPusingMinGW/MSYS;

thechangesthatwerenecessarywereveryminor.Perhapsthis

descriptionwillhelpothersuselibtcconWindows.

First,asmallbugtoreport:

Intcc.cthefunctiontcc_basename()followstheline:

#if!

defined(LIBTCC)

butthefunctiontcc_basename()isusedinpe_build_exports()in

tccpe.c--movingthe#iflinebelowthefunctiontcc_basename()

eliminatesalinkerrorbuildinglibtcc.dllinPEtargetmode.

Second,configuringandmakingtccwithMSYSplacesapathnamein

config.hinMSYSformat.Forexample,Ipassedtheargument

--prefix=/c/Dev/tcc

toconfigure;

thispathwasgoodforbuildingtcc.exeanddidn'

t

containanyspaces,unlikethedefaultpath.Thiscreatestheline

#defineCONFIG_TCCDIR"

/c/Dev/tcc"

inconfig.h.Manuallychangingthislineto

C:

/Dev/tcc"

enableslibtcc.dlltofindtheincludefilesandlibrariesoncethe

libraryisbuilt.[Theapplicationtcc.exeavoidsthisproblemby

settingtcc_lib_pathfromtheapplication'

sdirectoryatstartup.A

similarsolutioncouldbeusedforthelibraryusingDllMain.]

So,afterconfigure,fixCONFIG_TCCDIRinconfig.handmake.

Finally,thelibrarylibtcc.dllcanbebuiltwiththeMSYScommand:

gcc-O2-shared-Wall-Wl,--export-all-symbols/

-mpreferred-stack-boundary=2/

-march=i386-falign-functions=0-fno-strict-aliasing/

-DTCC_TARGET_PE-DLIBTCC-olibtcc.dlltcc.c

Belowisadiffoftcc-0.9.23tcc.candthechangesforLIBTCCwith

TCC_TARGET_PEandDLLlocationoflibraryfiles.

Regards,

e

$diff-u../tcc-0.9.23-o/tcc.ctcc.c

---../tcc-0.9.23-o/tcc.cFriJun1718:

09:

152005

+++tcc.cTueFeb2817:

03:

442006

@@-10157,8+10157,6@@

flag_name,value);

}

-#if!

-

/*extractthebasenameofafile*/

staticconstchar*tcc_basename(constchar*name)

{

@@-10175,6+10173,35@@

returnp;

+#ifdefined(LIBTCC)

+

+#ifdefWIN32

+int__stdcallDllMain(void*hinstDLL,unsignedlongfdwReason,void*

lpvReserved)

+{

+if(fdwReason==1/*DLL_PROCESS_ATTACH*/)

+{

+/*onwin32,asimplementedinmain()

+wesupposethelibandincludesareatthelocationofthislibrary

+*/

+staticcharpath[1024];

+char*p,*d;

+GetModuleFileNameA(hinstDLL,path,sizeofpath);

+p=d=strlwr(path);

+while(*d)

+if(*d=='

//'

)*d='

/'

p=d;

+++d;

+}

+*p='

/0'

+tcc_lib_path=path;

+return1/*TRUE*/;

+}

+#endif

+#else/*!

LIBTCC*/

staticint64_tgetclock_us(void)

#ifdefWIN32

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 育儿知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1