Up: Library tips [Contents][Index]
°Ü¿¢À¤Î¹â¤¤C¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ò½ñ¤¯¤³¤È¤ÏÆñ¤·¤¯¡¤¤½¤ì¤Ï°Û¤Ê¤ë·Á¼°¤Î¥³¥ó ¥Ñ¥¤¥é¤ÇÆÉ¤Þ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¤¿¤á¤Ç¤¹¡¥
C++¥³¥ó¥Ñ¥¤¥é¤Ï¡¤C¤è¤ê¶¯¸Ç¤Ë·Á¼°²½¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¤´°Á´¤Ê¥×¥í¥È¥¿¥¤¥×¤Ç
Àë¸À¤µ¤ì¤¿´Ø¿ô¤òÍ׵ᤷ¤Þ¤¹¡¥C´Ø¿ô¤ÈÊÑ¿ô¤Ï¡¤Ì¾Á°¤¬¤ª¤«¤·¤¯¤Ê¤é¤Ê¤¤¤è¤¦
¤Ë¡¤extern "C"
¥Ç¥£¥ì¥¯¥Æ¥£¥Ö¤ÇÀë¸À¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥libtool
¤ÇC++¤Î»ÈÍѤ˴ØÏ¢¤·¤¿¤½¤Î¾¤ÎÌäÂê¤Ï¡¤See C++ libraries.
ANSI C¥³¥ó¥Ñ¥¤¥é¤Ï¡¤C++¥³¥ó¥Ñ¥¤¥é¤Û¤É¸·Ì©¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¤´Ø¿ô¤Î¥×¥í
¥È¥¿¥¤¥×¤Ï¡¤¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ò#include
¤·¤¿¤È¤¤ÎÉÔɬÍפʷٹð¤òÈò
¤±¤ë¤¿¤á¡¤¹Ô¤¦Êý¤¬Îɤ¤¤Ç¤·¤ç¤¦¡¥
Non-ANSI¥³¥ó¥Ñ¥¤¥é¤Ï¡¤´Ø¿ô¤¬¥×¥í¥È¥¿¥¤¥×¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¤¥¨¥é¡¼¤òÊó¹ð¤· ¤Þ¤¹¡¥
¤³¤ì¤é¤ÎÊ£»¨¤µ¤Ï¡¤¾åµ¤½¤ì¤¾¤ì¤Î¥³¥ó¥Ñ¥¤¥é¤òÍøÍѲÄǽ¤Ë¤¹¤ë¤¿¤á¡¤¥é¥¤¥Ö ¥é¥ê¥¤¥ó¥Õ¥¡¡¼¥Õ¥§¡¼¥¹¥Ø¥Ã¥À¤Ç¡¤¤¤¤¯¤Ä¤«¤ÎC¥×¥ê¥×¥í¥»¥Ã¥µ¤ÎËâË¡¤ò»ÈÍÑ ¤¹¤ëɬÍפ¬¤¢¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡¥
libtoolÇÛÉÛʪ¤Îdemo¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤Îfoo.h¤Ï¡¤°ÂÁ´¤Ë¥·¥¹ ¥Æ¥à¥Ç¥£¥ì¥¯¥È¥ê¤Ë¥¤¥ó¥¹¥È¡¼¥ë²Äǽ¤Ê¡¤¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Î½ñ¤Êý¤ÎÎã¤òÄó¶¡ ¤·¤Þ¤¹¡¥
¤½¤Î¥Õ¥¡¥¤¥ë¤Î´ØÏ¢¤¹¤ëÉôʬ¤Ï¡¤°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
/* BEGIN_C_DECLS should be used at the beginning of your declarations, so that C++ compilers don't mangle their names. Use END_C_DECLS at the end of C declarations. */ #undef BEGIN_C_DECLS #undef END_C_DECLS #ifdef __cplusplus # define BEGIN_C_DECLS extern "C" { # define END_C_DECLS } #else # define BEGIN_C_DECLS /* empty */ # define END_C_DECLS /* empty */ #endif /* PARAMS is a macro used to wrap function prototypes, so that compilers that don't understand ANSI C prototypes still work, and ANSI C compilers can issue warnings about type mismatches. */ #undef PARAMS #if defined (__STDC__) || defined (_AIX) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined(WIN32) || defined(__cplusplus) # define PARAMS(protos) protos #else # define PARAMS(protos) () #endif
¤³¤ì¤é¤Î¥Þ¥¯¥í¤Ï¡¤°Ê²¼¤Î¤è¤¦¤Ëfoo.h¤Ç»ÈÍѤµ¤ì¤Þ¤¹¡¥
#ifndef FOO_H #define FOO_H 1 /* The above macro definitions. */ #include "…" BEGIN_C_DECLS int foo PARAMS((void)); int hello PARAMS((void)); END_C_DECLS #endif /* !FOO_H */
#ifndef FOO_H¤¬¡¤foo.h¤ÎËÜÂΤò¡¤Í¿¤¨¤é¤ì¤¿¥³¥ó¥Ñ¥¤¥ë¤Ç°ì ²ó°Ê¾åÆÉ¤ß¹þ¤à¤³¤È¤òÈò¤±¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡¥
¤Þ¤¿¡¤BEGIN_C_DECLS
/END_C_DECLS
¤ÎÁȤγ°Â¦¤¢¤ë¤â¤Î¤À¤±¤¬¡¤
#include
¹Ô¤Ë¤¢¤ê¤Þ¤¹¡¥¸·Ì©¤Ë¤¤¤¦¤È¡¤¤½¤ì¤Ï¡¤ÊݸɬÍפÊC¤Î¥·¥ó
¥Ü¥ë̾¤Ç¤¹¤¬¡¤¥Ø¥Ã¥À¤ÎÆâÍÆ¤ÎÃæ¿´¼þÊդˤ³¤ì¤é¤Î¥Þ¥¯¥í¤Îñ°ì¤ÎÁȤ¬¤¢¤ë¾ì
¹ç¡¤¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Ï¤è¤ê´ÉÍý¤·¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡¥
PARAMS
¡¤BEGIN_C_DECLS
¡¤¤½¤·¤ÆEND_C_DECLS
¤Î¤³¤ì¤é
¤ÎÄêµÁ¤òÆÈ¼«¤Î¥Ø¥Ã¥À¤Ç»ÈÍѤ¹¤Ù¤¤Ç¤¹¡¥¤½¤·¤Æ¡¤C++¡¤ANSI¡¤¤½¤·¤ÆÈóANSI
¤Î¥³¥ó¥Ñ¥¤¥é7¤Ç͸ú¤Ê¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¡¤¤½
¤ì¤é¤ò»ÈÍѤ¹¤ë¤³¤È¤¬²Äǽ¤È¤Ê¤ê¤Þ¤¹¡¥
°Ü¿¢²Äǽ¤Ê¥³¡¼¥É¤ò¥Í¥¤¥Æ¥£¥Ö¤Ë½ñ¤«¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡¤¾åµ¤Î¥Ò¥ó¥È¤Ë³¤±¤ë ¤³¤È¤Ç¡¤ºÇ¤âÌÀÇò¤ÊÌäÂê¤ò̵¤¯¤¹¤³¤È¤ËÌòΩ¤Á¤Þ¤¹¤¬¡¤ÌÀ¤é¤«¤ËÊ̤ÎÈù̯¤ÊÌä Â꤬¤¢¤ê¤Þ¤¹¡¥°Ê²¼¤ÎÌäÂê¤ËÂн褹¤ëɬÍפ¬¤¢¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡¥
void *
¤ò¾ï¤Ë¥µ¥Ý¡¼¥È
¤¹¤ë¤ï¤±¤Ç¤Ï¤Ê¤¯¡¤¤½¤³¤Ç¤Ïchar *
¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥
const
¡¤signed
¤½¤·¤Æsigned
¥¡¼¥ï¡¼¥É¤Ï¡¤¥µ¥Ý¡¼¥È¤µ
¤ì¤Æ¤¤¤Ê¤¤¥³¥ó¥Ñ¥¤¥é¤â¤¢¤ê¡¤ÆÃ¤ËANSI°ÊÁ°¤Î¥³¥ó¥Ñ¥¤¥é¤¬¤¢¤²¤é¤ì¤Þ¤¹¡¥
long double
·¿¤Ï¡¤Â¿¤¯¤Î¥³¥ó¥Ñ¥¤¥é¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡¥
²æ¡¹¤Ï¡¤__P
¡¤__BEGIN_DECLS
¤½¤·¤Æ
__END_DECLS
¤Î»ÈÍѤò¿ä¾©¤·¤Æ¤¤¤Þ¤·¤¿¡¥¥¢¥ó¥À¡¼¥¹¥³¥¢¤Ç»Ï¤Þ¤ë¥·¥ó
¥Ü¥ë(¤È¥×¥ê¥×¥í¥»¥Ã¥µ¥Þ¥¯¥í¤µ¤¨¤â)¤¬¥³¥ó¥Ñ¥¤¥é¤Î»ÈÍѤÇͽÌó¤µ¤ì¤Æ¤¤¤ë¤Î
¤Ç¡¤°¤¤¥¢¥É¥Ð¥¤¥¹¤Ç¤·¤¿¡¥