We investigate which practical constraints are imposed by foregrounds to the detection of the B-mode polarization generated by gravitational waves in the case of experiments of the type currently being planned. Because the B-mode signal is probably dominated by foregrounds at all frequencies, the detection of the cosmological component depends drastically on our ability for removing foregrounds. We provide an analytical expression to estimate the level of the residual polarization for Galactic foregrounds, according to the method employed for their subtraction. We interpret this result in terms of the lower limit of the tensor-to-scalar ratio r that allows to disentangle the cosmological B-mode polarization from the foregrounds contribution. Polarized emission from extragalactic radio sources and gravitational lensing is also taken into account. As a first approach, we consider the ideal limit of an instrumental noise--free experiment: for a full--sky coverage and a degree resolution, we obtain a limit of r~10^(-4). This value can be improved by high--resolution experiments and, in principle, no clear fundamental limit on the detectability of gravitational waves polarization is found. Our analysis is also applied to planned or hypothetical future polarization experiments, taking into account expected noise levels.