From: Glenn Morris <rgm@gnu.org>
To: emacs-devel@gnu.org
Cc: Dan Nicolaescu <dann@ics.uci.edu>
Subject: byte-compiler warnings about undefined functions can now be silenced
Date: Sun, 18 Nov 2007 19:39:36 -0500 [thread overview]
Message-ID: <18240.56136.448503.860758@fencepost.gnu.org> (raw)
In-Reply-To: <ur9oddrnmg0.fsf@mothra.ics.uci.edu>
Dan Nicolaescu wrote:
> Could you please post a message to emacs-devel about how to use this
> feature?
>
> An example with the warning that is currently produced by the byte
> compiler and how to use this to get rid of it.
As requested...
When bootstrapping, there are lots of messages about functions that
are "not known to be defined". The compiler is technically correct, but
the code is usually such that when it actually runs, the function will
be defined.
For example, byte-compiling fortran.el used to warn:
In end of data:
fortran.el:2152:1:Warning: the function `gud-find-c-expr' is not known
to be defined.
But gud-find-c-expr was only used in the function that fortran mode
uses for the local value of `gud-find-expr-function'. So this would
only ever be called from gud, so the warning can safely be suppressed.
It's nice to do this, so that real warnings are more visible.
All you need to do is add a `declare-function' statement before the
first use of the function in question:
(declare-function gud-find-c-expr "gud.el" nil)
This says that gud-find-c-expr is defined in "gud.el" (the `.el' can
be omitted). The file path is either absolute, or relative to the one
with the declare-function statement (e.g. "../files.el").
The 3rd argument is optional, and specifies the argument list of
gud-find-c-expr. In this case, it takes no arguments (`nil' is
different from not specifying a value). In other cases, this might be
something like (file &optional overwrite). You don't have to specify
the argument list, but if you do the byte-compiler will check that the
calls match the declaration.
The functions `check-declare-file' and `check-declare-directory' will
check that all the declare-function statements in a file or directory
are true (i.e. that the functions are defined in the specified files,
and have the same argument lists, if specified). `make check-declare'
will check all of leim/ and lisp/.
> Also, IMO it would be good to add declare-function to the 22.2
> branch, (even as an empty stub if it's considered too risky), this
> should help with compatibility between the 2 branches.
I don't have much of an opinion. It could easily be added as a no-op
(it's almost a no-op now...).
next prev parent reply other threads:[~2007-11-19 0:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-10 0:55 suppressing byte-compiler warnings about undefined functions Glenn Morris
2007-11-10 3:13 ` Stefan Monnier
2007-11-10 17:54 ` Richard Stallman
2007-11-11 1:11 ` Glenn Morris
2007-11-11 4:00 ` Glenn Morris
2007-11-11 19:33 ` Richard Stallman
2007-11-13 4:20 ` Glenn Morris
2007-11-13 9:31 ` martin rudalics
2007-11-14 5:32 ` Glenn Morris
2007-11-14 14:53 ` Stefan Monnier
2007-11-15 3:07 ` Richard Stallman
2007-11-17 3:58 ` Glenn Morris
2007-11-17 23:30 ` Richard Stallman
2007-11-13 20:02 ` Richard Stallman
2007-11-13 21:05 ` Stefan Monnier
2007-11-14 5:30 ` Glenn Morris
2007-11-15 3:06 ` Richard Stallman
[not found] ` <ur9oddrnmg0.fsf@mothra.ics.uci.edu>
2007-11-19 0:39 ` Glenn Morris [this message]
2007-11-19 9:04 ` byte-compiler warnings about undefined functions can now be silenced martin rudalics
2007-11-24 3:12 ` Glenn Morris
2007-11-19 19:02 ` Richard Stallman
2007-11-20 4:05 ` Glenn Morris
2007-11-19 19:33 ` Jay Belanger
2007-11-19 20:46 ` Glenn Morris
2007-11-20 12:12 ` Richard Stallman
2007-11-11 8:46 ` suppressing byte-compiler warnings about undefined functions Alan Mackenzie
2007-11-11 15:51 ` Dan Nicolaescu
2007-11-11 16:10 ` Alan Mackenzie
2007-11-11 16:18 ` Dan Nicolaescu
2007-11-11 18:32 ` Dan Nicolaescu
2007-11-11 23:54 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18240.56136.448503.860758@fencepost.gnu.org \
--to=rgm@gnu.org \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.