Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python31ÓëC½»»¥

1.cµ÷ÓÃpython:
   ÊµÀý´úÂ룺
main.cµ÷ÓÃtest.pyµÄ
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//main.c
#include <windows.h>
#include <python.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
     Py_Initialize() ;//initialize the python system
    PyObject * py= PyImport_ImportModule("test");
    Py_Finalize();//Finalize  the python system
}
    
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Ïà¹ØÎĵµ£º

#ÔÚCÖеÄÃîÓÃÄãÖªµÀ¶àÉÙ

CÖеÄ#ºÅ²»½öÊÇ#include£¬#defineµÈµÄ¹Ø¼ü×ÖÊ×ʹÓöøÒÑ£¬#ÔÚºêÖл¹ÓкܶàÓ÷¨¡£¾ßÌåÇë¿´ÏÂÃæÎÒÀ´¾ÙÀý
1.Ë«#ºÅµÄºêÓ÷¨¡£
ÎÒÏàÐÅË«##ºÅµÄÓ÷¨Ó¦¸Ã´ó²¿·ÖÈ˶¼¼û¹ý°É£¬Ö÷ÒªÊÇÓÃÀ´Á¬½Óºê±äÁ¿ÃûʹÓã¬ÔÚGCC²Î¿¼ÊÖ²áÖÐÕâÑù¼ÇÔØ¡£
¿ÉÓÃÓÚºêÄÚ²¿½«Á½¸öÔ´´úÂëȨ±êÁ¬½Ó³ÉÒ»¸öµÄÁ¬½Óָʾ×Ö£¬¿ÉÓÃÀ´¹¹Ôì²»»á±»½âÎöÆ÷´íÎó½âÊ͵ÄÃû×Ö¡£ ......

CÏÝÚ壺ÅжϺêÊÇ·ñµÈÓÚÒ»¸ö³£Êý

ÏÂÃæÕâ¶Î´úÂëÓÐɶ´íÎó£¿
#if ULONG_MAX == 0xFFFFFFFF
inline unsigned long byte_swap(unsigned long x) { return __builtin_bswap32(x); }
inline long byte_swap(long x) { return __builtin_bswap32(x); }
#else
inline unsigned long byte_swap(unsigned long x) { return __builtin_bswap64(x); }
inline long ......

ʹÓÃpdb½øÐÐpythonµÄµ÷ÊÔ

1 ÔÚÏëÒª²åÈë¶ÏµãµÄµØ·½²åÈë´úÂë
                import pdb
                pdb.set_trace()
2È»ºóʹÓÃÖ¸Áî½øÐÐdebug
²é¿´´úÂëÉÏÏÂÎÄ£¬l£¨Ð¡Ð´L£©
¼àÊÓ±äÁ¿ ......

extern "C"

extern "C" °üº¬Ë«Öغ¬Ò壬´Ó×ÖÃæÉϼ´¿ÉµÃµ½£ºÊ×ÏÈ£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä´Î£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£ÈÃÎÒÃÇÀ´Ïêϸ½â¶ÁÕâÁ½Öغ¬Òå¡£
¡¡¡¡£¨1£© ±»extern "C"ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
¡¡¡¡externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü×Ö¸æËß±àÒ ......

C/C++ ºê´øÀ´µÄÆæ¼¼ÒùÇÉ

×÷ÕߣºKevin Lynx¡¡À´Ô´£ºC++²©¿Í
ת×Ô:http://www.kuqin.com/language/20080319/4797.html
ÖÚ¶àC++Êé¼®¶¼ÖÒ¸æÎÒÃÇCÓïÑÔºêÊÇÍò¶ñÖ®Ê×£¬µ«ÊÂÇé×ܲ»ÈçÎÒÃÇÏëÏóµÄÄÇô»µ£¬¾ÍÈçͬgotoÒ»Ñù¡£ºêÓÐ
Ò»¸öºÜ´óµÄ×÷Ó㬾ÍÊÇ×Ô¶¯ÎªÎÒÃDzúÉú´úÂë¡£Èç¹û˵ģ°å¿ÉÒÔΪÎÒÃDzúÉú¸÷ÖÖÐͱðµÄ´úÂë(ÐͱðÌæ»»)£¬
ÄÇôºêÆäʵ¿ÉÒÔΪÎÒÃÇÔÚ·ûºÅÉÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ