Attempting to print SerialPort inputs to the console

Viewed 49

First my code:

#include <iostream>
#include <thread>
#using <System.dll>

using namespace System;
using namespace System::IO::Ports;
using namespace System::Threading;

int main()
{
    SerialPort^ mySerialPort = gcnew SerialPort("COM5");
    mySerialPort->BaudRate = 9600;
    mySerialPort->Parity = Parity::None;
    mySerialPort->StopBits = StopBits::One;
    mySerialPort->DataBits = 8;
    mySerialPort->Handshake = Handshake::None;
    mySerialPort->RtsEnable = true;

    while (1)
    {
        Console::WriteLine(Console::ReadLine());
    }
}

The idea was to read from the SerialPort and write to the console. Source

Originally I was going to use:

std::cout << Console::ReadLine() << '\n';

However, that had an error (ReadLine outputs String^ not String, I don't know the difference) and I was hoping for something to compile.

With the above code I received the error: two-phase name lookup is not supported for C++/CLI ... use /Zc:twoPhase-

The error recommends I use /Zc:twoPhase- which is a compiler option. So I enabled it and got the error: Element has an invalid value of "Yes(/permissive-) /Zc:twoPhase-"

I'm not quite sure how to proceed from here.

Apologies I'm a beginner and I dove way over my head. Any help would be appreciated! Note: I included thread, I know this code doesn't use it, but I plan on using it later.

2 Answers

There is no solution. I got an "cannot open file 'MSCOREE.lib'" error. It appears that file no longer exists in Windows and I didn't know how to get ahold of it. So I used the Visual Studio Windows Form App.

Edit: eXCore's comment about the .NET framework solved it.

Related