For Programmers: Free Programming Magazines  


Home > Archive > Smartphone Developer Forum > January 2005 > about error C2065









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author about error C2065
Dreamer

2005-01-23, 4:04 pm

i learn about the code hellosp written by douglas boling ,when i build it
,some error
happened.
the error is :
"E:\projects\HelloSP\HelloSP.cpp(114) : error C2065: 'x0' : undeclared
identifier"
below is the hellosp.cpp.

// ========================================
===========================
//HelloSP
//
//
// ========================================
===========================

#include <windows.h>
#include <commctrl.h>
#include <aygshell.h>
#include "hellosp.h"
//-------------------------------------------------------------------
//global data

const TCHAR szAppName[] = TEXT("HelloSP");
HINSTANCE hInst;

//message dispatch table for Mainwindowproc
const struct decodeUINT MainMessages[] = {
WM_CREATE, DoCreateMain,
WM_PAINT, DoPaintMain,
WM_COMMAND, DoCommandMain,
WM_DESTROY, DoDestroyMain,
};

//command message dispatch for mainwindowproc
const struct decodeCMD MainCommandItems[] = {
IDM_EXIT, DoMainCommandExit,
};

// ========================================
===========================

//program entry point
//
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE HPrevInstance,
LPWSTR lpCmdLine, int nCmdShow) {
MSG msg;
int rc = 0;
HWND hwndMain;
hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
if (hwndMain ==0) return 0x10;

//application message loop

while (GetMessage (&msg, NULL, 0, 0)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
//Instance cleanup
return TermInstance (hInstance, msg.wParam);
}

//-------------------------------------------------------------------
//InitInstance Instance initlization

HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow) {
WNDCLASS wc;
HWND hWnd;
hInst = hInstance;
hWnd = FindWindow (szAppName,NULL);
if (hWnd) {
SetForegroundWindow ((HWND)(((DWORD)hWnd) |0x01));
return 0;
}

//register application main window class.
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;

if (RegisterClass (&wc) == 0) return 0;

//create main window

hWnd = CreateWindow (szAppName,
TEXT("hellosp"),
WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);

if (!IsWindow (hWnd)) return 0;

ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);
return hWnd;
}

//-------------------------------------------------------------------
//Term instance
//
int TermInstance (HINSTANCE hInstance, int nDefRC) {
return nDefRC;
}

// ========================================
===========================
//windows proc
//

LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
int i; // the error marked here
for (i = 0 ; i < dim(MainMessages); i++) {
if (wMsg == MainMessages[i].Code)
return (*MainMessages[i].Fxn)(hWnd, wMsg, wParam, lParam);
}
return DefWindowProc (hWnd, wMsg, wParam, lParam);
}

//-------------------------------------------------------------------

LRESULT DoCreateMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
SHMENUBARINFO mbi;
//create menubar.

memset (&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = ID_MENU;
mbi.hInstRes = hInst;

//Create menubar

if (!SHCreateMenuBar (&mbi)) {
MessageBox (hWnd,TEXT("can't create menu bar"),szAppName, MB_OK);
DestroyWindow (hWnd);
}

//size the window th fit above menubar

RECT rect, rectDesk;
int cx, cy;
GetWindowRect (mbi.hwndMB,&rect);
GetWindowRect (GetDesktopWindow(), &rectDesk);
cx = rectDesk.right - rectDesk.left;
cy = (rectDesk.bottom - rectDesk.top) - (rect.bottom - rect.top);
SetWindowPos (hWnd, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER);

SHSetNavBarText (hWnd, TEXT("hello"));
return 0;
}

//-------------------------------------------------------------------
//do command main

LRESULT DoCommandMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
WORD idItem, wNotifyCode;
HWND hwndCtl;
int i;

idItem =(WORD) LOWORD (wParam);;
hwndCtl = (HWND) lParam;

for (i = 0 ; i<dim(MainCommandItems); i++) {
if (idItem == MainCommandItems[i].Code)
return (*MainCommandItems[i].Fxn)(hWnd, idItem, hwndCtl,
wNotifyCode);
}

return 0;
}

//-------------------------------------------------------------------
//do paintMain

LRESULT DoPaintMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
PAINTSTRUCT ps;
HPEN hPen,hOld;
RECT rect;
HDC hdc;

hdc = BeginPaint (hWnd, &ps);
GetClientRect (hWnd, &rect);
hPen = CreatePen (PS_SOLID, 1, RGB (255, 0, 0));
hOld = (HPEN)SelectObject (hdc, hPen);
Rectangle (hdc,rect.left, rect.top, rect.right, rect.bottom);
SelectObject (hdc, hOld);
DeleteObject (hPen);

DrawText (hdc, TEXT("Hello smart phone "), -1, &rect,
DT_CENTER | DT_VCENTER | DT_SINGLELINE);

EndPaint (hWnd, &ps);
return 0;
}

//-------------------------------------------------------------------

//do destroy main window

LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
PostQuitMessage (0);
return 0;
}

// ========================================
===========================
// do maincommand exit

LPARAM DoMainCommandExit (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
SendMessage (hWnd, WM_CLOSE, 0, 0);
return 0;
}


riki

2005-01-23, 4:04 pm

Dreamer wrote:
> i learn about the code hellosp written by douglas boling ,when i build it
> ,some error
> happened.
> the error is :
> "E:\projects\HelloSP\HelloSP.cpp(114) : error C2065: 'x0' : undeclared
> identifier"
> below is the hellosp.cpp.


There are a few bugs in this code :-(, but feel free to ask as you come
accross them.

The bug you have is in the hellosp.h file, you should have a line like this:
#define dim(x) (sizeof(x) / sizeof(x[0]))
to get that error it might (incorrectly) be this:
#define dim(x) (sizeof(x) / sizeof(x0))
so just add those square brackets back in and that should get it going
again.

riki

main(){printf("%d != %d, why?", sizeof('"')["'"],
,(sizeof('"'))["]\"\0["]);}
By Night:
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
By Day: http://www.EmbeddedFusion.com
Dreamer

2005-01-23, 4:04 pm

tks. very useful. there is an error in hellosp.h
like this :
#define dim(x) (sizeof(x0)/sizeof(x[0]))
~~~
I just looking for the error in the file Hellosp.cpp ,so can't find it .

thank you very much.


"riki" wrote:

> Dreamer wrote:
>
> There are a few bugs in this code :-(, but feel free to ask as you come
> accross them.
>
> The bug you have is in the hellosp.h file, you should have a line like this:
> #define dim(x) (sizeof(x) / sizeof(x[0]))
> to get that error it might (incorrectly) be this:
> #define dim(x) (sizeof(x) / sizeof(x0))
> so just add those square brackets back in and that should get it going
> again.
>
> riki
>
> main(){printf("%d != %d, why?", sizeof('"')["'"],
> ,(sizeof('"'))["]\"\0["]);}
> By Night:
> ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
> AbstractStart for Smartphone :
> http://homepages.inspire.net.nz/~gambit/AbstractStart/
> By Day: http://www.EmbeddedFusion.com
>

riki

2005-01-23, 4:04 pm

Dreamer wrote:
> tks. very useful. there is an error in hellosp.h
> like this :
> #define dim(x) (sizeof(x0)/sizeof(x[0]))
> ~~~
> I just looking for the error in the file Hellosp.cpp ,so can't find it .

Are you using this:
http://msdn.microsoft.com/library/d...Application.asp

if you are then you should have three files, hellosp.cpp, hellosp.h and
hellosp.rc. The line to check is in hellosp.h, NOT hellosp.cpp

riki

main(){printf("%d != %d, why?\n", sizeof('"')["'"],
(sizeof('"'))["]\"\0["]);}
By Night:
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
By Day: http://www.EmbeddedFusion.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com