emacs-devel
[Top][All Lists]
Advanced

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

Re: Free variable warning about bbdb-version (bug#19678)


From: Tassilo Horn
Subject: Re: Free variable warning about bbdb-version (bug#19678)
Date: Fri, 06 Mar 2015 10:09:06 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Thomas Fitzsimmons <address@hidden> writes:

Hi Thomas,

> I'm trying to make eudcb-bbdb.el compatible with BBDB 2 and BBDB 3.
> To check the version, I need something like:
>
> (if (version<= "3" bbdb-version) ...)
>
> but the byte compiler warns:
>
> Warning: reference to free variable `bbdb-version'
>
> I'd rather not introduce a new warning.  Is there a good way to handle
> this?  Adding (defvar bbdb-version) to eudcb-bbdb.el seems wrong,
> since the version check is assuming it's a constant defined by the
> external BBDB package.

(defvar bbdb-version) is exactly what you are looking for.  The defvar
without init-value just tells the byte-compiler that you make sure this
variable will be there at the right time so he hasn't to worry about it.

,----[ (info "(elisp)Warning Tips") ]
|    • Try to avoid compiler warnings about undefined free variables, by
|      adding dummy ‘defvar’ definitions for these variables, like this:
| 
|           (defvar foo)
| 
|      Such a definition has no effect except to tell the compiler not to
|      warn about uses of the variable ‘foo’ in this file.
`----

Since you require bbdb on top of the file anyway, you can be sure that
`bbdb-version' is correctly initialized from the external bbdb package
when the version check takes place.

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]