Re: [PATCH v2] commit-slab: declare functions "static inline"

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v2] commit-slab: declare functions "static inline"

From: Thomas Rast <hidden>
Date: 2016-06-15 22:59:19

Jonathan Nieder [off-list ref] writes:
Thomas Rast wrote:
quoted
This shuts up compiler warnings about unused functions.
If that is the only goal, I think it would be cleaner to use

	#define MAYBE_UNUSED __attribute__((__unused__))

	static MAYBE_UNUSED void init_ ...

like was done in the vcs-svn/ directory until cba3546 (drop obj_pool,
2010-12-13) et al.

I haven't thought carefully about whether encouraging inlining here
(or encouraging the reader to think of these functions as inline) is a
good or bad change.
Hmm.

I actually had this idea after seeing the same trick in khash.h.  Is
__atribute__((__unused__)) universal?  If so, maybe we could apply the
same also to khash?  If not, I'd rather go with the inline.

-- 
Thomas Rast
tr@thomasrast.ch

Re: [PATCH v2] commit-slab: declare functions "static inline"

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:59:19

Thomas Rast wrote:
Jonathan Nieder [off-list ref] writes:
quoted
Thomas Rast wrote:
quoted
quoted
This shuts up compiler warnings about unused functions.
If that is the only goal, I think it would be cleaner to use

	#define MAYBE_UNUSED __attribute__((__unused__))

	static MAYBE_UNUSED void init_ ...

like was done in the vcs-svn/ directory until cba3546 (drop obj_pool,
2010-12-13) et al.

I haven't thought carefully about whether encouraging inlining here
(or encouraging the reader to think of these functions as inline) is a
good or bad change.
Hmm.

I actually had this idea after seeing the same trick in khash.h.  Is
__atribute__((__unused__)) universal?  If so, maybe we could apply the
same also to khash?  If not, I'd rather go with the inline.
The khash functions are very small, so it very well may make sense for
them to be inline.

git-compat-util.h (or compat/msvc.h) defines __attribute__(x) to an
empty sequence of tokens except on HP C and gcc.  Attribute unused has
existed at least since GCC 2.95.

Unfortunately HP C doesn't support attribute __unused__. :(
http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/pragmas.htm#Attributes

On the bright side, it would be easy to work around using a
conditional definition of MAYBE_UNUSED for the sake of HP C.  From
August 2010 until March 2011 nobody noticed.

Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help