extern "C"µ×²ãÔÀí
ͨ³££¬ÔÚCÓïÑÔµÄÍ·ÎļþÖо³£¿ÉÒÔ¿´µ½ÀàËÆÏÂÃæÕâÖÖÐÎʽµÄ´úÂ룺
#ifdef __cplusplus
extern "C" {
#endif
/**** some declaration or so *****/
#ifdef __cplusplus
}
#endif /* end of __cplusplus */
ÄÇô£¬ÕâÖÖд·¨Ê²Ã´ÓÃÄØ£¿Êµ¼ÊÉÏ£¬ÕâÊÇΪÁËÈÃCPPÄܹ»ÓëC½Ó¿Ú¶ø²ÉÓõÄÒ»ÖÖÓï·¨ÐÎʽ¡£Ö®ËùÒÔ²ÉÓÃÕâÖÖ·½Ê½£¬ÊÇÒòΪÁ½ÖÖÓïÑÔÖ®¼äµÄһЩ²îÒìËùµ¼Öµġ£ÓÉÓÚCPPÖ§³Ö¶à̬ÐÔ£¬Ò²¾ÍÊǾßÓÐÏàͬº¯ÊýÃûµÄº¯Êý¿ÉÒÔÍê³É²»Í¬µÄ¹¦ÄÜ£¬CPPͨ³£ÊÇͨ¹ý²ÎÊýÇø·Ö¾ßÌåµ÷ÓõÄÊÇÄÄÒ»¸öº¯Êý¡£ÔÚ±àÒëµÄʱºò£¬CPP±àÒëÆ÷»á½«²ÎÊýÀàÐͺͺ¯ÊýÃûÁ¬½ÓÔÚÒ»Æð£¬ÓÚÊÇÔÚ³ÌÐò±àÒë³ÉΪĿ±êÎļþÒÔºó£¬CPP±àÒëÆ÷¿ÉÒÔÖ±½Ó¸ù¾ÝÄ¿±êÎļþÖеķûºÅÃû½«¶à¸öÄ¿±êÎļþÁ¬½Ó³ÉÒ»¸öÄ¿±êÎļþ»òÕß¿ÉÖ´ÐÐÎļþ¡£µ«ÊÇÔÚCÓïÑÔÖУ¬ÓÉÓÚÍêȫûÓжà̬ÐԵĸÅÄC±àÒëÆ÷ÔÚ±àÒëʱ³ýÁË»áÔÚº¯ÊýÃûÇ°ÃæÌí¼ÓÒ»¸öÏ»®ÏßÖ®Í⣬ʲôҲ²»»á×ö£¨ÖÁÉٺܶà±àÒëÆ÷¶¼ÊÇÕâÑù¸ÉµÄ£©¡£ÓÉÓÚÕâÖÖµÄÔÒò£¬µ±²ÉÓÃCPPÓëC»ìºÏ±à³ÌµÄʱºò£¬¾Í¿ÉÄÜ»á³öÎÊÌâ¡£¼ÙÉèÔÚijһ¸öÍ·ÎļþÖж¨ÒåÁËÕâÑùÒ»¸öº¯Êý£º
int foo(int a, int b);
¶øÕâ¸öº¯ÊýµÄʵÏÖλÓÚÒ»¸ö.cÎļþÖУ¬Í¬Ê±£¬ÔÚ.cppÎļþÖе÷ÓÃÁËÕâ¸öº¯Êý¡£ÄÇô£¬µ±CPP±àÒëÆ÷±àÒëÕâ¸öº¯ÊýµÄʱºò£¬¾ÍÓпÉÄÜ»á°ÑÕâ¸öº¯ÊýÃû¸Ä³É_fooii£¬ÕâÀïµÄii±íʾº¯ÊýµÄµÚÒ»²ÎÊýºÍµÚ¶þ²ÎÊý¶¼ÊÇÕûÐÍ¡£¶øC±àÒëÆ÷È´ÓпÉÄܽ«Õâ¸öº¯ÊýÃû±àÒë³É_foo¡£Ò²¾ÍÊÇ˵£¬ÔÚCPP±àÒëÆ÷µÃµ½µÄÄ¿±êÎļþÖУ¬foo()º¯ÊýÊÇÓÉ_fooii·ûºÅÀ´ÒýÓõģ¬¶øÔÚC±àÒëÆ÷Éú³ÉµÄÄ¿±êÎļþÖУ¬foo()º¯ÊýÊÇÓÉ_fooÖ¸´úµÄ¡£µ«Á¬½ÓÆ÷¹¤×÷µÄʱºò£¬Ëü¿É²»¹ÜÉϲã²ÉÓõÄÊÇʲôÓïÑÔ£¬ËüÖ»ÈÏÄ¿±êÎļþÖеķûºÅ¡£ÓÚÊÇ£¬Á¬½ÓÆ÷½«»á·¢ÏÖÔÚ.cppÖе÷ÓÃÁËfoo()º¯Êý£¬µ«ÊÇÔÚÆäËüµÄÄ¿±êÎļþÖÐÈ´ÕÒ²»µ½_fooiiÕâ¸ö·ûºÅ£¬ÓÚÊÇÌáʾÁ¬½Ó¹ý³Ì³ö´í¡£extern "C" {}ÕâÖÖÓï·¨ÐÎʽ¾ÍÊÇÓÃÀ´½â¾öÕâ¸öÎÊÌâµÄ¡£±¾ÎĽ«ÒÔʾÀý¶ÔÕâ¸öÎÊÌâ½øÐÐ˵Ã÷¡£
Ê×ÏȼÙÉèÓÐÏÂÃæÕâÑùÈý¸öÎļþ£º
/* file: test_extern_c.h */
#ifndef __TEST_EXTERN_C_H__
#define __TEST_EXTERN_C_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* this is a test function, which calculate
* the multiply of a and b.
*/
extern int ThisIsTest(int a, int b);
#ifdef __cplusplus
}
#endif /* end of __cplusplus */
#endif
ÔÚÕâ¸öÍ·ÎļþÖÐÖ»¶¨ÒåÁËÒ»¸öº¯Êý£¬ThisIsTest()¡£Õâ¸öº¯Êý±»¶¨ÒåΪһ¸öÍⲿº¯Êý£¬¿ÉÒÔ±»°üÀ¨µ½ÆäËü³ÌÐòÎļþÖС£¼ÙÉèThisIsTest()º¯ÊýµÄʵÏÖ
Ïà¹ØÎĵµ£º
¿¼²éÒ»¸ö³õ¼¶Ç¶Èëʽϵͳ¿ª·¢ÈËÔ±µÄC»ù±¾¹¦£¬¸½Óдð°¸ÌâÄ¿ÓÉ×ÊÉîǶÈëʽϵͳר¼ÒÄⶨ,Ä¿µÄÊÇ¿¼²éÈëÃż¶µÄǶÈëʽÈí¼þ¿ª·¢ÈËÔ± Gavin ShawÌṩÏêϸ½â´ð
±àÕß°´:·Ç³£»ù±¾¹ØÓÚCÓïÑÔµÄÎÊÌâ,Ò»¸öÐÅÏ¢Àà(¼ÆËã»ú,×ÊѶ¹¤³Ì,µç×Ó¹¤³Ì, ͨÐŹ¤³Ì)רҵµÄ±¾¿Æ±ÏÒµÉúÓ¦¸Ã´ïµ½µÄˮƽ¡£ÌâÄ¿²»ÄÑ,È«²¿¶¼ÄÜ¿ìËٵشðÍ꣬µ±È»Ò²ÐèÒªÒ»¶¨µ ......
BioscomʹÓÃ×¢Ò⣺´®¿Ú½ÓÏß·½Ê½Îª4£¬6£»7£¬8·Ö±ð¶Ì½Ó¡£½ö´Ëº¯ÊýÒªÇó¡£
·ñÔò»áÔì³ÉÖ»ÄܽÓÊÜÎÞ·¨·¢ËÍÊý¾Ý¡£º¯Êý·µ»ØÖµ´íÎó£¡
º¯ÊýÃû: bioscom
¹¦ ÄÜ: ²Ù×÷portÖ¸¶¨µÄRS232Ò첽ͨѶ¿Ú
ÓÃ ......
¡¾ÔÐÍ¡¿
type fun( type arg1, type arg2, ...
);
¡¾ÃèÊö¡¿
Ö÷ÒªÓÃÔÚ²ÎÊý¸öÊý²»È·¶¨µÄº¯ÊýÖУ¬ÀýÈ磺printfº¯Êý¡£
¡¾Ê¹Ó÷½·¨¡¿
²Î¿¼£ºglib/manual/Add.c
#include <stdarg.h>
#include <stdio.h>
int add_em_up (int coun ......
char* my_strrev( char* string )
{
char *left, *right, ch;
left = right = string;
while( *right++ != '\0');
right -= 2;
while( left<right )
{
ch = *left;
*left = *right;
*right = ch;
++left; --right;
&n ......
http://www.cnblogs.com/hoodlum1980/archive/2007/08/15/857067.html
Ìâ¸É£ºÊäÈëÁ½¸ö½Ï´óµÄÊý£¬Êä³öÏà³ËµÄ½á¹û¡£
Òâ˼Ҳ¾ÍÊÇÁ½¸öÊýºÜ´ó£¬³¬³öÁËintµÄ´æ´¢·¶Î§¡£
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100
void GetDigits( ......