in SDCC Compiler User Guide I read the following:
void to_buffer( unsigned char c )
{
c; // to avoid warning: unreferenced function argument
__asm
; save used registers here.
; If we were still using r2,r3 we would have to push them here.
; if( head != (unsigned char)(tail-1) )
mov a,_tail
dec a
xrl a,_head
; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
jz t_b_end$
;
; buf[ head++ ] = c;
mov a,dpl ; dpl holds lower byte of function argument
mov dpl,_head ; buf is 0x100 byte aligned so head can be used directly
mov dph,#(_buf>>8)
movx @dptr,a
inc _head
; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
t_b_end$:
; restore used registers here
__endasm;
}
I don't understand what does the sentence "c; // to avoid warning: unreferenced function argument"
mean, is it a special usage of SDCC? Or a special usage of C language?
Compilers tend to warn you if you have an incoming function parameter that you don't use. In your case, c;
is a void operation to access the variable and to avoid the warning. It is similar to
int func(char c)
{
(void)c;
//c is never used in the function
}
FWIW, in gcc
, to enable the warning, -Wunused-parameter
option is used. (enabled in -Wextra
)