A function is real iff the coefficients of complex fourier series $c_{-n}=\overline{c_n}$ Given $f$ be a $2\pi$-periodic complex-valued function which is integrable on $[−\pi, \pi]$. Write $$f(x) \sim \sum_{n=-\infty}^{\infty}c_ne^{inx}$$ and
$$\overline {f(x)} \sim \sum_{n=-\infty}^{\infty}d_ne^{inx}$$
But even if I can prove $f$ and $\bar f$ have the same fourier series, what I can conclude is that they are equal almost everywhere except on a null set. $f$ may still be complex-valued on a null set.
How can we actually prove this?

Suppose $c_{-n} = \overline{c_n}$.  Then \begin{align*}
\sum_{n = -\infty}^\infty c_n \mathrm{e}^{\mathrm{i} n x}  &= c_0 \mathrm{e}^{\mathrm{i} 0 x} + \sum_{n = 1}^\infty c_n \mathrm{e}^{\mathrm{i} n x} + c_{-n} \mathrm{e}^{-\mathrm{i} n x}  \\
&= c_0 + \sum_{n = 1}^\infty c_n \mathrm{e}^{\mathrm{i} n x} + \overline{c_{n}} \mathrm{e}^{-\mathrm{i} n x}  \\
&= c_0 + \sum_{n = 1}^\infty c_n \mathrm{e}^{\mathrm{i} n x} + \overline{c_{n} \mathrm{e}^{\mathrm{i} n x}}  \text{.}
\end{align*}
First, $c_0 = \overline{c_0}$, so $c_0 \in \mathbb{R}$.  Then, the summand is $z_n + \overline{z_n} \in \mathbb{R}$ for each $n$.
Converse: read bottom to top.
Technical detail: To justify the reorganization of the sum in the first line, sneak up on the summations through the sequence of trigonometric polynomials $\left(\sum_{n=-N}^{N} c_n \mathrm{e}^{\mathrm{i} nx}\right)_{N=0}^\infty$.  The trigonometric polynomials are dense in the continuous functions on the circle (under the uniform norm), which are dense in the integrable functions on the circle.  Moving diagonally through the resulting sequence of sequences, we get a sequence of trigonometric polynomials approaching $f(x)$.
