  In the context of Sobolev spaces with variable exponents,
Poincar\'e--Wirtinger inequalities are possible as soon as Luxemburg norms are
considered. On the other hand, modular versions of the inequalities in the
expected form \begin{equation*}
  \int_\Omega \left|f(x)-\langle f\rangle_{\Omega}\right|^{p(x)} \ {\mathrm{d}
x}
  \leqslant C \int_\Omega|\nabla f(x)|^{p(x)}{\mathrm{d} x},
  \end{equation*} are known to be \emph{false}. As a result, all available
modular versions of the Poincar\'e- Wirtinger inequality in the
variable-exponent setting always contain extra terms that do not disappear in
the constant exponent case, preventing such inequalities from reducing to the
classical ones in the constant exponent setting. Our contribution is threefold.
First, we establish that a modular Poincar\'e--Wirtinger inequality
particularizing to the classical one in the constant exponent case is indeed
conceivable. We show that if $\Omega\subset \mathbb{R}^n$ is a bounded
Lipschitz domain, and if $p\in L^\infty(\Omega)$, $p \geq 1$, then for every
$f\in C^\infty(\bar\Omega)$ the following generalized Poincar\'e--Wirtinger
inequality holds
  \begin{equation*}
  \int_\Omega \left|f(x)-\langle f\rangle_{\Omega}\right|^{p(x)} \ {\mathrm{d}
x}
  \leq C \int_\Omega\int_\Omega \frac{|\nabla f(z)|^{p(x)}}{|z-x|^{n-1}}\
{\mathrm{d} z}{\mathrm{d} x},
  \end{equation*}
  where $\langle f\rangle_{\Omega}$ denotes the mean of $f$ over $\Omega$, and
$C>0$ is a positive constant depending only on $\Omega$ and
$\|p\|_{L^\infty(\Omega)}$. Second, our argument is concise and constructive
and does not rely on compactness results. Third, we additionally provide
geometric information on the best Poincar\'e--Wirtinger constant on Lipschitz
domains.
