奇怪的“错误:预期')'之前';'令牌”但我找不到它

时间:2013-10-08 12:25:02

标签: c++

YAxis::YAxis() {
    TextWriter *tw = new MBTextWriter;
    Create(Y_AXIS_WIDTH, Y_AXIS_HEIGHT);
    SetPosition(Y_AXIS_STARTING_X, Y_AXIS_STARTING_Y);
    SetFocus();
    SetColor(114, 114, 114);
    for (unsigned int y = 0; y < Y_AXIS_HEIGHT / GRID_CELL_HEIGHT; y++) {
        if (y >= 10)
            tw->SetPosition(8, y * GRID_CELL_HEIGHT + 14);
        else
            tw->SetPosition(8, y * GRID_CELL_HEIGHT + 9);
        tw->SetMessage(toString(y));
        tw->Write(); 
    }
}

此错误似乎以此构造函数为中心,但我看不到它。 任何帮助将不胜感激。

完全错误:

Editor/YAxis.cpp: In constructor ‘YAxis::YAxis()’:
Editor/YAxis.cpp:6:33: error: expected ‘)’ before ‘;’ token
Editor/YAxis.cpp:6:50: error: expected primary-expression before ‘)’ token
Editor/YAxis.cpp:6:50: error: expected ‘;’ before ‘)’ token

如果您需要有关我尝试使用此代码完成的更多信息,请告诉我。

1 个答案:

答案 0 :(得分:2)

如果第6行是这一行:

for (unsigned int y = 0; y < Y_AXIS_HEIGHT / GRID_CELL_HEIGHT; y++) {

问题可能出在宏的定义中:

  • Y_AXIS_HEIGHT
  • GRID_CELL_HEIGHT

你能提供他们的内容吗?