[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
compiler hints
From: |
Dirk Herrmann |
Subject: |
compiler hints |
Date: |
Tue, 5 Jun 2001 23:25:52 +0200 (MEST) |
Hello folks,
in error.h, the macro SCM_NORETURN is defined. When compiling on gcc,
this macro expands to a compiler hint telling the compiler that the
corresponding function will never return. This is a nice option offered
by gcc, since it eliminates a lot of compiler warnings without need to add
some dummy return statement at different points of the code. Further, it
is usefull for a developer, since it offers additional information about
the code.
I figured out that when guile is compiled with the -W option in addition
to -Wall, gcc complains about a lot of unused function parameters. A few
probes showed, that these are no bugs - some function just provide some
extra parameters for the sake of a clean interface, even if not all of
them are used. However, the compiler still warns about such places. For
this situation, gcc offers the possibility to mark a variable, function or
function parameter as potentially unused.
Thus, I suggest:
* Add a section {Compiler hints} to __scm.h
* Move the definition of SCM_NORETURN from error.h to __scm.h
* Add a definition SCM_UNUSED to __scm.h
* Add SCM_UNUSED to intentionally unused parameters.
There are further compiler hints available with gcc. For example, the gcc
function attribute 'const' declares a function to be sideeffect free,
which potentially allows for more compiler optimizations. Thus, it may
make sense to use a common naming scheme for compiler hints like
SCM_HINT_NORETURN or something similar instead of plain SCM_NORETURN or
SCM_UNUSED. Hints for other compilers than gcc could be added in the same
way.
Best regards,
Dirk Herrmann
- compiler hints,
Dirk Herrmann <=
- Re: compiler hints, Martin Grabmueller, 2001/06/05
- Re: compiler hints, Marius Vollmer, 2001/06/09
- Re: compiler hints, Matthias Koeppe, 2001/06/11
- Re: compiler hints, Michael Livshin, 2001/06/11
- Re: compiler hints, thi, 2001/06/11
- Re: compiler hints, Michael Livshin, 2001/06/11
- Re: compiler hints, Dale P. Smith, 2001/06/11
- Re: compiler hints, Rob Browning, 2001/06/11
- Re: compiler hints, Dale P. Smith, 2001/06/11
- Re: compiler hints, Marius Vollmer, 2001/06/11