Jump to content
  • Advertisement

AdamTurner

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

100 Neutral

About AdamTurner

  • Rank
    Newbie
  1. AdamTurner

    error C2143 using if() and macro

    Thanks this solved my issue, thanks to everyone
  2. AdamTurner

    error C2143 using if() and macro

    I see how this works but my main issue is defining a macro "ERRORWND" #define ERRORWND(msg) \ { \ MessageBox(NULL, msg, L"Window Initialisation ERROR!", \ MB_OK|MB_ICONEXCLAMATION) \ } \ Which can be reused to show error's, then in code i can just write the ERRORWND(L"Failed to Register Window Class"); The message from ERRORWND will always show in the message box title that the error is "Window Initialisation ERROR!" MessageBox(NULL, msg, L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION). Where 'msg' is this can hold the actual message that happened at the specific call ERRORWND(L"Failed to Register Window Class");. In theory yes i could be less lazy and use the MessageBox(NULL,L"Specific Error",L"Type of "Error", MB_OK|MB_ICONEXCLAMATION), but is you can see im trying to make is so I call the "Type Error" and only have to fill in the "Specific Error". To elaberate on the issue I originally have, is that, // register the window class if(RegisterClassEx(&wc)) { //{ ERRORWND(L"Failed to Register Window Class"); } MessageBox(NULL, NULL, L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION); return 0; } This above code is a simple test to register the WindowClassEx which im sure most people if not all will use to catch errors, the problem is calling my defined macro within the if(){} statements brackets. I have always managed my error handling this way, and im just getting used to the subtle difference's between VC++ EX 2008 and VC+ EX 2010. But again i thank you for your help, I will just be less lazy with my attempts to handle errors.
  3. AdamTurner

    error C2143 using if() and macro

    Definition is here // Include WinAPI header file(s) #include <windows.h> #include <windowsx.h> // Macros and Constants // Error Handling // Error MessageBox Macro #define ERRORWND(msg) \ { \ MessageBox(NULL, msg, L"Window Initialisation ERROR!", \ MB_OK|MB_ICONEXCLAMATION) \ } \ // Define constant paramenter's // Window Width and Height #define WINDOW_WIDTH 1280 #define WINDOW_HEIGHT 800 // Window Position X & Y #define WINDOW_POS_X #define WINDOW_POS_Y The code generating the error is here // this struct holds information for the window class WNDCLASSEX wc; // clear out the window class for use ZeroMemory(&wc, sizeof(WNDCLASSEX)); // fill in the struct with the needed information wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // | CS_NOCLOSE; wc.lpfnWndProc = WindowProc; wc.hInstance = hInst; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = L"WindowClass1"; // register the window class if(!RegisterClassEx(&wc)) { ERRORWND(L"Failed to Register Window Class"); return 0; } // calculate the size of the client area RECT wr = {0, 0, 500, 400}; // set the size, but not the position AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); // adjust the size // create the window and use the result as the handle hWnd = CreateWindowEx(NULL, L"WindowClass1", // name of the window class L"Our First Windowed Program", // title of the window WS_OVERLAPPEDWINDOW, // window style 300, // x-position of the window 300, // y-position of the window wr.right - wr.left, // width of the window wr.bottom - wr.top, // height of the window NULL, // we have no parent window, NULL NULL, // we aren't using menus, NULL hInst, // application handle NULL); // used with multiple windows, NULL the error given back to me by the complier is; 1>c:\users\adam\desktop\c++ projects\windows\window template v1.0\window template v1.0\windowsupport.hpp(86): error C2143: syntax error : missing ';' before '}'
  4. Im unsure why im receiving error C2143 this worked fine in 2008 VC++ EX but in 2010 VC++ EX im having quite a few issues // register the window class if(!RegisterClassEx(&wc)) { ERRORWND(L"Failed to Register Window Class"); return 0; } Any help to understand the issue further would be greatly appreciated.
  5. AdamTurner

    Trouble Defining Error macro

    Thank you very much guys, that sorted my issue out and great for future reference
  6. [font="arial, verdana, tahoma, sans-serif"] Here is a snippet from the header file, the problem is Error c2447 when defining the Message-box macro exasusted my self on this and thought i'd ask for helpski[/font] // Include guard(s) to ensure the file is only add once #ifndef WINDOWSUPPORT_HPP #define WINDOWSUPPORT_HHP // Include WinAPI header file(s) #include <windows.h> #include <windowsx.h> // Macros and Constants // Error Handling #define ERRORWND(msg) { // Error MessageBox Macro MessageBox(NULL, msg, L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION); } // Define constant paramenter's // Window Width and Height #define WINDOW_WIDTH 1280 #define WINDOW_HEIGHT 800 // Window Position X & Y #define WINDOW_POS_X #define WINDOW_POS_Y // Initialisation Any help would be fantastic Also this is and will be complied on Express 2k10 C++ Thanks Adam
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!