3

I'm currently coding an app that will use OCR to read page numbers. I am using Visual Studio 2013 on a PC. I'm using C++ with OpenCV and Tesseract to complete this.

An error keeps on coming up and while I have come across similar problems, I can't find anything where it specific relates to the identifier 'and'. As such, I don't know how to fix this problem. Here is the section of code that it applies to:

vector<string> PgNrOCR::runRecognition(const vector<Mat> &pgnrImage, int                   pgnrType)
{
    vector<string> output;

    output.resize(pgnrImage.size());

    for (size_t i = 0; i < pgnrImage.size(); i++)
    {
        if (!pgnrImage[i].empty() and pgnrType == 1)
            output[i] = runPrediction1(pgnrImage[i], i);
        if (!pgnrImage[i].empty() and pgnrType == 2)
            output[i] = runPrediction2(pgnrImage[i], i);
    }
    return (output);
}

The 'and' identifiers in the if statement are bringing up the error, so I need to find an alternative solution. The full error appears as so.

Error 3 error C2146: syntax error : missing ')' before identifier 'and' c:\users\andrew\documents\visual studio 2013\projects\project1\project1\pgnrocr.cpp 152 1 PgTurn

I appreciate any help!

ApesInChains
  • 31
  • 1
  • 3

1 Answers1

0

can you try && instead of and?

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Ghooo
  • 496
  • 1
  • 3
  • 11
  • `&&` and `and` are lexically equivalent in conforming C++. – chris Sep 01 '15 at 05:17
  • ok nvm, check this on how to enable alternative operators http://en.cppreference.com/w/cpp/language/operator_alternative – Ghooo Sep 01 '15 at 05:17
  • @chris oh first time to know that, do you know if this was always the case with all versions of C++? – Ghooo Sep 01 '15 at 05:20
  • 1
    To my knowledge, it has been like this since the beginning (at least the first standard). C has required the inclusion of a header. – chris Sep 01 '15 at 05:22
  • might still be the reason: https://stackoverflow.com/questions/24414124/why-does-vs-not-define-the-alternative-tokens-for-logical-operators – Felix B. Feb 05 '21 at 12:27