3

I am an absolute newbie in Windows (I usually work on macOS/Linux).

I am trying to help my student to compile my C++ code in Windows but we are not succeeding. We have narrowed the problem down to this minimal example

#include <iostream>

int main()
{
  int i = 10;

  if ( i == 10 or i == 100 )
    std::cout << "..." << std::endl;
}

This gives the error

cl /std:c++14 so.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26131.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

so.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.13.26128\include\xlocale(313): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
so.cpp(7): error C2146: syntax error: missing ')' before identifier 'or'
so.cpp(7): error C2065: 'or': undeclared identifier
so.cpp(7): error C2146: syntax error: missing ';' before identifier 'i'
so.cpp(7): error C2059: syntax error: ')'
so.cpp(8): error C2143: syntax error: missing ';' before 'std::cout'
so.cpp(7): warning C4553: '==': operator has no effect; did you intend '='?
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77

0 Answers0