unused for all platforms



Hi,

Currently there is a macro G_GNUC_UNUSED which works only for gcc. There are
some other possibilities for indicating unused parameter or variables so that
other compiler can benefit also.

I would recomend the following macros

G_UNUSED_PARAMETER marks a parameter as unused
G_UNUSED_VARIABLE 
	if compiling not release version marks the variable as unused
	if compiling release version aborts compilation


definitions (maybe in gmacros.h):

#define G_UNUSED_PARAMETER(p) p = *&p

#ifdef G_RELEASE
#define G_UNUSED_VARIABLE(v) #error "not used variable"
#else
#define G_UNUSED_VARIABLE(v) v = *&v
#endif

usage:
int f (int par)
{
	G_UNUSED_PARAMETER(par);

	return 5;
}


As I know there is no compiler that generates code for statements like
"p = *&p"


Is it OK to introduce these macros?
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]