Fortran & C »ì±à
C µ÷ÓÃ Fortran
c2ffn.f
SUBROUTINE NAMEAGE(NAME, NLEN, AGE, TEMP)
CHARACTER*(*) NAME
INTEGER NLEN,AGE
REAL TEMP
C
WRITE(6,1000) NAME(1:NLEN),AGE,TEMP
1000 FORMAT(1X,'Hello ',A,', who is ',I2,
. ' years old, has a temperature of ', f4.1)
RETURN
END
c2f.c
#include <string.h>
#ifdef _CRAY
# include <fortran.h>
# define nameage NAMEAGE
#else
# if !defined(_AIX) && !defined(__hpux)
# define nameage nameage_
# endif
# define _fcd char *
# define _cptofcd(a, b) (a)
# define _fcdlen(a) strlen(a)
#endif
void nameage(_fcd name, int *nlen, int *age, float *temp);
int main()
{
char *name = "Knut";
_fcd fp;
int nlen, age = 4;
float temp = 98.6;
nlen = strlen(name);
fp = _cptofcd(name, nlen);
nameage(fp, &nlen, &age, &temp);
system("pause");
return 0;
}
Makefile
f77 = g77
#
tar = demo
#
src = c2f.c
#
srcf = c2ffn.f
#
obj = $(src:.c=.o)
objf = $(srcf:.f=.o)
${tar} : ${obj} ${objf}
${f77} -o ${tar} ${objf} ${obj}
${obj} : ${src}
${CC} -c ${src} -o ${obj}
${objf} : ${srcf}
${f77} -c ${srcf} -o ${objf}
clean:
rm -f *.o
Fortran µ÷ÓÃ C
#include <string.h>
#ifdef _CRA
Ïà¹ØÎĵµ£º
λ¼ÆÊý¾ÍÊǶÔÒ»¸öÊýÖоßÓÐijЩÌØÕ÷µÄλ½øÐмÆÊý¡£¿´ÏÂÃæʵÏÖ£º
/* bitscount.c£ºÎ»¼ÆÊý */
/* ¼ÆËãxÖÐ1λµÄÊýÄ¿£º·½°¸1£¬²ÉÓ÷ÖÖβßÂÔ */
inline int pop(unsigned x){
/* ¶Ôÿ¸ö2λ×ֶΣ¬ÏÈÎö³öÆäÓҶ˵Ä1룬ÔÙÎö³öÆä×ó¶ËµÄ1λ£¬È»ºóÈÃÕâÁ½¸öλÏà¼Ó */
x=(x & 0x55555555)+((x>>1) & 0x555555 ......
ÔÚGmail TopLanguage Group Öп´µ½Ò»ÆªÎÄÕ“C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©”£¬´ó¼ÒµÄÌÖÂÛ¶¼ºÜ¼¤Àø£¬´ó¼Ò¶¼¾õµÃÕâƪÎÄÕÂдµÃºÜ°ô£¬ÎÒÏëÔÚGroupÀïµÄÅóÓѶ¼ÄÜÔÚLookgirlµÄÕâƪÎÄÕÂÀï»ñÒæ²»ÉÙ£¬Îª´Ë¶·µ¨ÔÚ´ËתÔظÃÎÄ£¬¹©¸ü¶àÅóÓѽ»Á÷¡¢Ñ§Ï°¡£
C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©
Õâ¸öÌâÄ¿´óµÄÓÐЩÀëÆ×£¬Êµ»°Ëµ£ ......
1¡¢Ñ¡ÔñºÏÊʵÄËã·¨ºÍÊý¾Ý½á¹¹
Ñ¡ÔñÒ»ÖÖºÏÊʵÄÊý¾Ý½á¹¹ºÜÖØÒª£¬Èç¹ûÔÚÒ»¶ÑËæ»ú´æ·ÅµÄÊýÖÐʹÓÃÁË´óÁ¿µÄ²åÈëºÍɾ³ýÖ¸ÁÄÇʹÓÃÁ´±íÒª¿ìµÃ¶à¡£Êý×éÓëÖ¸ÕëÓï¾ä¾ßÓÐÊ®·ÖÃÜÇеĹØϵ£¬Ò»°ãÀ´Ëµ£¬Ö¸Õë±È½ÏÁé»î¼ò½à£¬¶øÊý×éÔò±È½ÏÖ±¹Û£¬ÈÝÒ×Àí½â¡£¶ÔÓڴ󲿷ֵıàÒëÆ÷£¬Ê¹ÓÃÖ¸Õë±ÈʹÓÃÊý×éÉú³ÉµÄ´úÂë¸ü¶Ì£¬Ö´ÐÐЧÂʸü¸ß¡£
ÔÚÐí¶à ......
——³õ²½ÉèÏë
¡¡×î½üÒ»Ö±ÔÚѧϰOSGI·½ÃæµÄ֪ʶ¡£ÂòÁËÒ»±¾¡¶OSGIÔÀíºÍ×î¼Ñʵ¼ù¡·£¬¿ÉÊÇ»¹Ã»Óе½¡£Òź¶µÄÊÇ£¬OSGIÄ¿Ç°µÄ¼¸¸ö¿ªÔ´¿ò¼ÜÖ»Ö§³ÖJava£¬¶ÔCºÍC++¶¼²»Ö§³ÖµÄ¡£¿ÉϧÎÒÃǹ«Ë¾Ä¿Ç°Ö÷ÒªµÄ¿ª·¢ÓïÑÔ»¹ÊÇcºÍc++£¬¼´±ãÊÇÒý½øOSGI£¬ËùµÃµÄºÃ´¦·¶Î§ÓÐÏÞ¡£¶øÎÒ¶ÔËÉÉ¢ñîºÏµÄÄ£¿é»¯¿ª·¢ÏòÍùÒѾᣲéÁËÒ»ÏÂOSGI¶ÔC++Ö§ ......
2010-04-09
µÚÊ®ËÄÕ Ԥ´¦ÀíÆ÷
1¡¢#define Ìæ»»
ÔÚ³ÌÐòÖÐÀ©Õ¹#define¶¨Òå·ûºÅºÍºêʱ£¬ÐèÒªÉæ¼°¼¸¸ö²½Ö裻
¢Ù¡¢ÔÚµ÷Óúêʱ£¬Ê×ÏȶԲÎÊý½øÐмì²é£¬¿´¿´ÊÇ·ñ°üº¬ÁËÈκÎÓÉ#define¶¨ÒåµÄ·ûºÅ£¬Èç¹ûÊÇ£¬ËüÃÇÊ×Ïȱ»Ìæ»»£»
¢Ú¡¢Ìæ»»ÎļþËæºó±»²åÈëµ½³ÌÐòÖÐÔÀ´ÎļþµÄλÖ㬶ÔÓں꣬²ÎÊýÃû±»ËûÃǵÄÖµÌæ´ú£»
¢Û¡¢×î ......