all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* On byte compilation
@ 2023-09-17 18:32 Petteri Hintsanen
  2023-09-18 19:07 ` tpeplt
  0 siblings, 1 reply; 3+ messages in thread
From: Petteri Hintsanen @ 2023-09-17 18:32 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I'm converting some old code to use new bindat-type introduced in
Emacs 28.1.  I'd like to keep the legacy forms for backwards
compatibility with older emacsen.  But there is a problem with byte
compilation.

Toy example:

  (defconst foo-bindat-spec
    (eval-when-compile
      (if (fboundp 'bindat-type)
          (bindat-type  ;; new form
            (id uint 32))
        '((id u32))))  ;; legacy form
    "Bindat spec for foo.")

What I try to accomplish here is to assign to foo-bindat-spec either the
result of (bindat-type ...) or list '((id u32)), depending on whether
bindat-type macro is available or not.  However, Emacs' 27.2 byte
compiler complains:

  foo.el:5:14:Warning: reference to free variable ‘uint’

even though (fboundp 'bindat-type) evaluates to nil with that Emacs
version.  The resulting elc seems to be ok (?) despite the warning:

  #@22 Bindat spec for foo.
  (defconst foo-bindat-spec '((id u32)) (#$ . 408))

If I relocate eval-when-compile like this

  (defconst foo-bindat-spec
    (if (eval-when-compile (fboundp 'bindat-type))
        (bindat-type  ;; new form
          (id uint 32))
      '((id u32)))  ;; legacy form
    "Bindat spec for foo.")

then the byte compiler does not complain.  Could someone please explain
why?

Thanks,
Petteri




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-19 22:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-17 18:32 On byte compilation Petteri Hintsanen
2023-09-18 19:07 ` tpeplt
2023-09-19 22:47   ` tpeplt

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.