Boost logo

Boost Users :

Subject: [Boost-users] Access violation when setting up a serial port
From: Tangleman (tangleman_at_[hidden])
Date: 2011-03-11 10:37:40


This feels like it should be a very simple solution, but I'm very much a
Boost newbie, and relearning C++. I'm trying to set up a serial port in a
class constructor of a legacy program I am updating. The serial port and
io_service definitions are in the header file. The class is MFC.

Header file declarations:

boost::asio::serial_port port;
boost::asio::io_service io;

Here is the class constructor:

CCplusplus_TesterDlg::CCplusplus_TesterDlg(CWnd* pParent)
     : CDialog(CCplusplus_TesterDlg::IDD, pParent), port(io, "COM3")
{
     m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

If I comment out the port and io declaration and the port initialization
from the constructor, I can pass the constructor fine in debug mode.
However, if I leave them in, I get the following:

First-chance exception at 0x771a6b90 in Cplusplus_Tester.exe: 0xC0000005:
Access violation writing location 0xccccccd0.
Unhandled exception at 0x771a6b90 in Cplusplus_Tester.exe: 0xC0000005:
Access violation writing location 0xccccccd0.

Debug mode breaks in win_mutex.hpp at line 56:

::EnterCriticalSection (&crit_section);

Go ahead. Make me feel like an idiot. Any clues as to what I am doing
wrong?

Thanks!

--
View this message in context: http://boost.2283326.n4.nabble.com/Access-violation-when-setting-up-a-serial-port-tp3348369p3348369.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net