Why can we say that $\bar{d}Q=TdS$? When we introduce entropy we do this by saying that: $$\bar{d}Q=TdS.$$
Now I was wondering why this should be true? I know that by looking at a Carnot cycle, we do get this relation for reversible processes. But what about a general process?
 A: This relation is not true for general processes. For a closed system, the general relation is $\delta Q \leq TdS$, as is illustrated by the Clausius Theorem (http://en.wikipedia.org/wiki/Clausius_theorem).
Another way of writing it is $dS=\delta Q/T + dS_{irr}$ where $ dS_{irr}$ is the entropy change due to irreversibilitiy in the closed system transformation.
A: To add to Whelp's Answer. Even though the
$$\bar{d}Q=T\,dS$$
does not hold in an irreversible process, it still gives us something general. Consider a thermodynamic system linked to a system of reservoirs and which can only exchange heat and nothing else with the reservoirs. Let's call the thermodynamic system an engine for our convenience. Then the engine has a macrostate, defined e.g. by pressure and volume if it is a simple cylinder of working fluid and piston, but the macrostate may comprise any number of measurable quantities.
We move from point $P_1$ to $P_2$ in our macrostate space: even if we do so irreversibly, we could, in principle do this reversibly. And, for the whole set of reversible paths linking $P_1$ to $P_2$, there is only one value of the integral $\int_{P_1}^{P_2} \frac{{\rm d}\,Q}{T}$ independent of path, by dint of equality in the Clausius theorem in this case. 
What this means is that, once we have defined an $S_0$ at some point $P_0$, then there must be a function of macrostate alone defined by $S(P) = S_0 + \int_{\Gamma(P_0,\,P)}\frac{{\rm d}\,Q}{T}$ where $\Gamma(P_0,\,P)$ is any reversible path between $P_0$ and $P$.
If we move from $P_0$ to $P$ irreversibly, then we "create" entropy $S_{irr}$ in Whelp's notation and thus add $S_{irr} = \int_{P_0}^{P}\frac{{\rm d}\,Q}{T} - S(P)$ (where $S(P)$ is the function of state we've just defined) to the reservoirs in doing so.
