2015-04-01 24 views
0

我試圖將OpenBSD make移植到Linux上,但是我被使用__only_inline宏弄糊塗了。這個宏來自/usr/include/sys/cdefs.h其如下定義它:搞清楚在BSD上使用的__only_inline C宏

/* 
* __only_inline makes the compiler only use this function definition 
* for inlining; references that can't be inlined will be left as 
* external references instead of generating a local copy. The 
* matching library should include a simple extern definition for 
* the function to handle those references. c.f. ctype.h 
*/ 
#ifdef __GNUC__ 
# if __GNUC_PREREQ__(4, 2) 
#define __only_inline extern __inline __attribute__((__gnu_inline__)) 
# else 
#define __only_inline extern __inline 
# endif 
#else 
#define __only_inline static __inline 
#endif 

有人能解釋一下這個宏的目的是什麼?它在OpenBSD系統使用使targ.h:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/make/targ.h?rev=1.13&content-type=text/x-cvsweb-markup

回答

0

是不是評論不夠清楚? __only_inline定義只能用於可以內聯的地方。另一個定義必須存在於其他地方,用於無法內聯的地方。

你可能想看看來自NetBSD/pkgsrc的bmake。它是一個非常類似的Make,它已經被Autoconf處理過並且已經可以移植到GNU/Linux上。你可以在這裏找到最新版本:Bmake

一般來說,你可能完全忽略它(即刪除它),或將其轉換爲extern inline

如果你給Marc發電子郵件,他可能會告訴你他爲什麼在這種情況下使用它。