Jump to content
  • Advertisement

bcome

Member
  • Content Count

    151
  • Joined

  • Last visited

Community Reputation

122 Neutral

About bcome

  • Rank
    Member
  1. I'm trying to compile something like this: class ThreadedClass { public: boost::thread *this_thread; ThreadedClass(); ~ThreadedClass(); void operator ()(); } ThreadedClass::ThreadedClass() { this_thread = new boost::thread(*this); } ThreadedClass::~ThreadedClass() { if (this_thread) delete this_thread; } void ThreadedClass::operator ()() { std::cout << "void ThreadedClass::operator ()()!"; std::cout << std::endl; } I have this simplified class and the real class in the same project. The simplified class compiles just fine, yet the real one gives me: c:\some\folder\someproject\somesourcefile.cpp(36) : error C2664: 'boost::thread::thread(const boost::function0<R> &)' : cannot convert parameter 1 from 'Namespace::RealClass' to 'const boost::function0<R> &' with [ R=void ] and [ R=void ] Reason: cannot convert from 'Namespace::RealClass' to 'const boost::function0<R>' with [ R=void ] No constructor could take the source type, or constructor overload resolution was ambiguous What is wrong? Also I can't even do this: typedef void (*ThreadFunction)(); ThreadFunction = *this; I'm compiling under MSVC++ .net Toolkit 2003 with MSVC++ .net 2003 SE headers & libraries. Edit: line split for ease.
  2. Oh, right, I'd messed up the WNDPROC method and forgot to change that. Thanks!!!
  3. Oops, edited the original. // window handler LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: DestroyWindow(hWnd); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } // not handled return DefWindowProc(hWnd, uMsg, lParam, wParam); }
  4. The code: ATOM WindowAtom = NULL; HWND Window = NULL; int main() { WNDCLASSEX wndclassex; // open primary window ZeroMemory(&wndclassex, sizeof(WNDCLASSEX)); wndclassex.cbSize = sizeof(WNDCLASSEX); wndclassex.style = CS_CLASSDC; wndclassex.lpfnWndProc = (WNDPROC)WindowProc; wndclassex.cbClsExtra = 0; wndclassex.cbWndExtra = 0; wndclassex.hInstance = (HINSTANCE)GetModuleHandle(NULL); wndclassex.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAINICON)); wndclassex.hCursor = LoadCursor((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_POINTER)); wndclassex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndclassex.lpszMenuName = NULL; wndclassex.lpszClassName = CLASS_NAME; wndclassex.hIconSm = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAINICON)); WindowAtom = RegisterClassEx(&wndclassex); if (!WindowAtom) { printf("ERROR: !RegisterClassEx(...)\n"); printf("ERROR: GetLastError() == %lu\n", GetLastError()); goto exit; } Window = CreateWindow(CLASS_NAME, TITLE, WS_CAPTION | WS_SYSMENU, 0, 0, 640, 480, NULL, NULL, (HINSTANCE)GetModuleHandle(NULL), NULL); if (!Window) { printf("ERROR: !CreateWindow(...)\n"); printf("ERROR: GetLastError() == %lu\n", GetLastError()); goto exit; } ShowWindow(Window, SW_NORMAL); UpdateWindow(Window); // message pump here // exit return 0; exit: // wait for key press printf("\nHit any key to continue..."); getch(); return 0; } // window handler LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: DestroyWindow(hWnd); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } // not handled return DefWindowProc(hWnd, uMsg, lParam, wParam); } The output: ERROR: !CreateWindow(...) ERROR: GetLastError() == 0 I've done some testing and have found that RegisterClassEx doesn't fail, but GetLastError() after the call does return 2 (which has something to do with file not found). To see if GetLastError() was returning a previous value (not that it should) I had done a SetLastError(0), but GetLastError() still returned 2. I've tried comparing the code with other successful attempts, but I can't figure out what I'm doing wrong here. Thanks. [Edited by - bcome on July 29, 2004 4:24:03 PM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!