2

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 2

0

Judging by the "Element has an invalid value of "Yes(/permissive-) /Zc:twoPhase-"" you've put this compiler option where it does not belong. Make sure you know where it should go. E.g. Why do I have warning "C4199 two-phase name lookup is not supported for C++/CLI, C++/CX, or openmp"?

2
  • I tried that. I solved on error and gave me a new one. "cannot open file "MSCOREE.lib". Mar 14, 2021 at 23:42
  • @SaltyRusnPotato I looked it up and it looks like a problem with .NET Framework SDK. Here
    – eXCore
    Mar 14, 2021 at 23:52
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.