qt linux“QMAKE_CXXFLAGS + = -std = c ++ 11”相当于windows?

时间:2013-07-03 20:44:42

标签: c++ windows qt

我是新手,所以请原谅我,如果真的很蠢。

最近我在ubuntu中使用qt制作了一个项目,我使用“QMAKE_CXXFLAGS + = -std = c ++ 11”进行静态链接,一切顺利,所以我想为什么不在windows上重新编译它,我做了。

这是node.h

#ifndef NODE_H
#define NODE_H
#include <iostream>
#include <string>
#include "qcustomplot.h"
using namespace std;
class node
{
public:
double p[6];
string table[3000][9];

double splitPoints[8];
double giniA[8];//array of ginies obtained by partitioning on corresponding attributes
double gini;//gini of a dataset
int rowc=0;//row count
int colc=0;
int cc;
std::string label;
string a[9];
node* left=NULL;
node* right=NULL;
void plotGraph(QCustomPlot *customPlot);
int optimize(int);


};

#endif // NODE_H

当我运行我的项目时,我收到以下错误消息:

   In file included from ..\mining app final(hopefully)\/mythread.h:4,
             from ..\mining app final(hopefully)\/mainwindow.h:8,
             from ..\mining app final(hopefully)\main.cpp:2:
   ..\mining app final(hopefully)\/node.h:16: error: ISO C++ forbids initialization of  member 'rowc'
   ..\mining app final(hopefully)\/node.h:16: error: making 'rowc' static
   ..\mining app final(hopefully)\/node.h:16: error: ISO C++ forbids in-class   initialization of non-const static member 'rowc'
   ..\mining app final(hopefully)\/node.h:17: error: ISO C++ forbids initialization of member 'colc'
   ..\mining app final(hopefully)\/node.h:17: error: making 'colc' static
   ..\mining app final(hopefully)\/node.h:17: error: ISO C++ forbids in-class initialization of non-const static member 'colc'
   ..\mining app final(hopefully)\/node.h:21: error: ISO C++ forbids initialization of member 'left'
   ..\mining app final(hopefully)\/node.h:21: error: making 'left' static
   ..\mining app final(hopefully)\/node.h:21: error: invalid in-class initialization of static data member of non-integral type 'node*'
   ..\mining app final(hopefully)\/node.h:22: error: ISO C++ forbids initialization of   member 'right'
   ..\mining app final(hopefully)\/node.h:22: error: making 'right' static
   ..\mining app final(hopefully)\/node.h:22: error: invalid in-class initialization of         static data member of non-integral type 'node*'
   mingw32-make[1]: Leaving directory `C:/build-blah-vai-Debug'
   mingw32-make[1]: *** [debug/main.o] Error 1
   mingw32-make: *** [debug] Error 2
   01:36:17: The process "C:\MinGw\bin\mingw32-make.exe" exited with code 2.
   Error while building/deploying project blah (kit: vai)
   When executing step 'Make'
   01:36:17: Elapsed time: 00:02.

任何人都可以指导我如何解决这个问题吗?

我目前正在研究Qt 4.8.5-mingw(Windows 7)

2 个答案:

答案 0 :(得分:0)

对于我在Windows上的qt项目,我使用了“QMAKE_CXXFLAGS + = -std = c ++ 0x”来获得新标准功能。 MinGW 4.8(支持许多c ++ 11功能),您可以下载here

答案 1 :(得分:0)

为了避免使用任何c ++ 11功能,我编写了自己的“to_string()”和“to_Double()”函数并使用它们,现在它就像一个魅力!

以下是功能:

string toString(double)

string toString(double num)
{
std::stringstream ss;

ss << num;
std::string s(ss.str());

return s;
}

double toDouble(string)

 double toDouble(string s)
 {
  int i,j;
  double p=0;

  for(i=s.size()-1;(s[i]!='.')&&(i>=0);i--)
  {
    p+=1.0;
  }

  if(s[i]!='.')
  p=0;

  else
  {
  for(j=i;j<s.size();j++)
  s[j]=s[j+1];
  }
  istringstream myStream(s);
  unsigned int uintVar = 0;

  myStream >> uintVar;

  return (uintVar/(double)(pow(10.0,p)));
 }