  Winds of massive stars have density inhomogeneities (clumping) that may
affect the formation of spectral lines in different ways, depending on their
formation region. Most of previous and current spectroscopic analyses have been
performed in the optical or ultraviolet domain. However, massive stars are
often hidden behind dense clouds rendering near-infrared observations
necessary. Our objective is to investigate whether a spectroscopic analysis
using either optical or infrared observations results in the same stellar
parameters with comparable accuracy, and whether clumping affects them in
different ways. We analyzed optical and near-infrared observations of a set of
massive O stars with spectral types O4-O9.5 and all luminosity classes. We
obtain similar stellar parameters in the optical and the infrared, although
with larger uncertainties in the near-infrared, both with and without clumping,
albeit with some individual deviating cases. We find that the inclusion of
clumping improves the fit to H$_\alpha$ or HeII 4686 in the optical for
supergiants, as well as that of Br$_\gamma$ in the near-infrared, but it
sometimes worsens the fit to HeII 2.18$\mu$m. Globally, there are no
significant differences when using the clumping laws tested in this work. The
infrared can be used for spectroscopic analyses, giving similar parameters as
from the optical, though with larger uncertainties. The best fits to different
lines are obtained with different (linear) clumping laws, indicating that the
wind structure may be more complex than adopted in the present work. No
clumping law results in a better global fit, or improves the consistency
between optical and infrared stellar parameters. Our work shows that the
optical and infrared lines are not sufficient to break the dichotomy between
the mass-loss rate and clumping factor.
