I have simple random generator code that returns different numbers using cl and g++ compilers in Windows. Strangely, the same code in Qt doesn't return different numbers. The code is
#include <random>
#include <iostream>
class RandGen
{
public:
RandGen() : m_generator(m_seeder())
{
}
std::random_device m_seeder;
std::mt19937 m_generator;
int getNum()
{
std::uniform_int_distribution<> dist(0,5);
return dist(m_generator);
}
};
int main()
{
RandGen rg;
for(int i(0); i < 5; ++i){
std::cout << rg.getNum() << " ";
}
std::cout << std::endl;
return 0;
}
In Visual Studio, the result is
With g++ via cygwin, the result is
Now running same code with Qt using Desktop Qt 5.9.1 MinGW 32bit, it returns same values.
The .pro
file is
QT += core
QT -= gui
CONFIG += c++11
TARGET = Ports
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app