I naturally included

#include <iostream>
using namespace std;

but the following overloading not works

friend ostream& operator<<(ostream& stream, mystruct& x);

just if I included std::

friend std::ostream& operator<<(std::ostream& stream, mystruct& x);

Why it is necessary?

>> Why it is necessary?

Well, it shouldn't be... I tried the code separately on both GCC and minGW compilers, and both compiled well and didn't complain...

Try adding the statement

using std::ostream;

and try again...

using std::ostream; solves the problem
however I also use MinGW!?

I'm intrigued. Please post a complete (small!) program that exhibits the problem.

Sorry it was my fault, the using namespace was at wrong place