  We consider the generalized Wirtinger inequality \[ (\int_{0}^{T} a |u|^q
)^{1/q} \le C \biggm(\int_{0}^{T} a^{1-p} |u'|^{p}\biggm)^{1/p}, \] with
$p,q>1$, $T>0$, $a\in L^1[0,T]$, $a\ge0$, $a\not\equiv0$ and where $u$ is a
$T$-periodic function satisfying the constraint \[ \int_{0}^{T} a |u|^{q-2}u
=0. \] We provide the best constant $C>0$ as well as all extremals.
Furthermore, we characterize the natural functional space where the inequality
is defined.
