请问谁知道这是什么错误?急!!!

xiaoyupzy 2003-06-20 02:16:50
我直接在VC6里面打开一个老的例子程序,Omnidemo.mak文件,提示说这个程序是用vc1.5或更老的版本写的,问是否转换成新格式?先不管他,转换,然后编译,出来一大堆警告和一个错误:(请大家帮忙看看,给点提示,我从没用过SDK编程,可是这个是老板催着要的,HELP!!!)

--------------------Configuration: Omnidemo - Win32 Debug--------------------
Compiling resources...
D:\MyProjects\Vc\Omni200pNew\Source\omnipanl.h(58) : warning RC4005: 'IDCLOSE' : redefinition
D:\MyProjects\Vc\Omni200pNew\Source\omnianno.h(59) : warning RC4005: 'IDHELP' : redefinition
Compiling...
Omnidemo.c
D:\MyProjects\Vc\Omni200pNew\Source\omnipanl.h(58) : warning C4005: 'IDCLOSE' : macro redefinition
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winuser.h(7545) : see previous definition of 'IDCLOSE'
D:\MyProjects\Vc\Omni200pNew\Source\omnianno.h(59) : warning C4005: 'IDHELP' : macro redefinition
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winuser.h(7546) : see previous definition of 'IDHELP'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(193) : warning C4028: formal parameter 1 different from declaration
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(193) : warning C4028: formal parameter 2 different from declaration
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(208) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(239) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(244) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(329) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(329) : warning C4113: 'int (__stdcall *)()' differs in parameter lists from 'int (__stdcall *)(struct HWND__ *,unsigned int ,unsigned int ,long )'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(566) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(566) : warning C4113: 'int (__stdcall *)()' differs in parameter lists from 'int (__stdcall *)(struct HWND__ *,unsigned int ,unsigned int ,long )'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(578) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(578) : warning C4113: 'int (__stdcall *)()' differs in parameter lists from 'int (__stdcall *)(struct HWND__ *,unsigned int ,unsigned int ,long )'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1435) : warning C4047: 'function' : 'struct HWND__ *' differs in levels of indirection from 'unsigned short '
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1435) : warning C4024: 'GetDlgCtrlID' : different types for formal and actual parameter 1
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1802) : warning C4028: formal parameter 2 different from declaration
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1802) : warning C4028: formal parameter 3 different from declaration
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1806) : warning C4133: '=' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1807) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
D:\MyProjects\Vc\Omni200pNew\Source\Omnidemo.c(1836) : warning C4133: 'function' : incompatible types - from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Linking...
.\Omnidll.lib : fatal error LNK1136: invalid or corrupt file
Error executing link.exe.

Omnidemo.exe - 1 error(s), 22 warning(s)
...全文
520 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyupzy 2003-06-25
  • 打赏
  • 举报
回复
问题还是没解决,先给分吧!
zxm954712 2003-06-20
  • 打赏
  • 举报
回复
INT_PTR DialogBoxParamEx(
HINSTANCE hInstance, // handle to module
LPCTSTR lpTemplateName, // dialog box template
HWND hWndParent, // handle to owner window
DLGPROC lpDialogFunc, // dialog box procedure
LPARAM dwInitParam // initialization value
);
INT_PTR CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

you should declare a function which proto type is same as above DialogProc and it is the forth paramter of function DialogBoxParamEx

about other error you may see the MDSN about the detail of function
yujun22 2003-06-20
  • 打赏
  • 举报
回复
up
xiaoyupzy 2003-06-20
  • 打赏
  • 举报
回复
谢谢!不过我不懂,HINSTANCE 和 HANDLE 有什么区别啊?

还有,

--------------------Configuration: Omnidemo - Win32 Debug--------------------
Compiling...
Omnidemo.cpp
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(332) : error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (__stdcall *)(void)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(569) : error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (__stdcall *)(void)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(581) : error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'int (__stdcall *)(void)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1438) : error C2664: 'GetDlgCtrlID' : cannot convert parameter 1 from 'unsigned short' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1805) : error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *,unsigned short,unsigned short,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(2082) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.

Omnidemo.exe - 6 error(s), 0 warning(s)

大家再帮帮忙,就剩这几个问题了:)
zxm954712 2003-06-20
  • 打赏
  • 举报
回复
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)

try it:)
oyd 2003-06-20
  • 打赏
  • 举报
回复
不能自动转换,你就强制转换看看
至于这条错误
C2731: 'WinMain' : function cannot be overloaded
只要把winmain的参数类型HANDLE改为HINSTANCE就可以了
xiaoyupzy 2003-06-20
  • 打赏
  • 举报
回复
谢谢,重定义已解决了。

但是还有一些错误如下:(附上代码)

--------------------Configuration: Omnidemo - Win32 Debug--------------------
Compiling...
Omnidemo.cpp
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(196) : error C2731: 'WinMain' : function cannot be overloaded
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(189) : see declaration of 'WinMain'
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(204) : error C2440: '=' : cannot convert from 'void *' to 'struct HWND__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(212) : error C2664: 'LoadStringA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(242) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(247) : error C2664: 'LoadStringA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(332) : error C2664: 'DialogBoxParamA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(569) : error C2664: 'DialogBoxParamA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(581) : error C2664: 'DialogBoxParamA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1438) : error C2664: 'GetDlgCtrlID' : cannot convert parameter 1 from 'unsigned short' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1805) : error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *,unsigned short,unsigned short,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1809) : error C2440: '=' : cannot convert from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1810) : error C2664: 'LoadIconA' : cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(1839) : error C2664: 'UnregisterClassA' : cannot convert parameter 2 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\myprojects\vc\omni_demo\omnidemo\omnidemo.cpp(2082) : error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.

Omnidemo.exe - 14 error(s), 0 warning(s)


老是说不能转换参数是指的什么意思啊?
cannot convert parameter 1 from 'struct HWND__ *' to 'struct HINSTANCE__ *'
相关的WinMain()如下:


/*****************************************************************************
FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)

PURPOSE: Performs initialization and processes the message loop.
*****************************************************************************/
//int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
// LPSTR lpCmdLine,
// int nCmdShow)
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
/* HANDLE hInstance; handle for this instance */
/* HANDLE hPrevInstance; handle for possible previous instances */
/* LPSTR lpszCmdLine; long pointer to exec command line */
/* int nCmdShow; Show code for main window display */

{
MSG msg; /* MSG structure to store your messages */
int nRc; /* return value from Register Classes */
char str1[64]; /* utility string */

FARPROC lpfnARINITMsgProc;

strcpy(szAppName, "ARDEMO");
hInst = hInstance;
if (!hPrevInstance)
{
/* register window classes if first instance of application */
if ((nRc = nCwRegisterClasses()) == -1)
{
/* registering one of the windows failed */
LoadString(hInst, IDS_ERR_REGISTER_CLASS, szString,
sizeof(szString));
MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);
return nRc;
}
}
else /* another copy of this program is already running */
{
MessageBox(NULL, "OMNIDEMO is already loaded.", NULL,
MB_ICONEXCLAMATION);
return(-1);
}

/* create application's Main window */
hWndMain = CreateWindow(
szAppName, /* Window class name */
"General Scanning OMNI-200P-A4 Demonstration Program",
/* Window's title */
WS_CAPTION | /* Title and Min/Max */
WS_SYSMENU | /* Add system menu box */
WS_MINIMIZEBOX | /* Add minimize box */
WS_MAXIMIZEBOX | /* Add maximize box */
WS_THICKFRAME | /* thick sizeable frame */
WS_MAXIMIZE | /* create maximized window */
WS_CLIPCHILDREN | /* don't draw in child windows areas */
WS_OVERLAPPED,
CW_USEDEFAULT, 0, /* Use default X, Y */
CW_USEDEFAULT, 0, /* Use default X, Y */
NULL, /* Parent window's handle */
NULL, /* Default to Class Menu */
hInst, /* Instance of window */
NULL); /* Create struct for WM_CREATE */


if(hWndMain == NULL) /* if could not create main window */
{
LoadString(hInst, IDS_ERR_CREATE_WINDOW, szString, sizeof(szString));
MessageBox(NULL, szString, NULL, MB_ICONEXCLAMATION);
return IDS_ERR_CREATE_WINDOW;
}

/* display main window */
ShowWindow(hWndMain, SW_SHOWMAXIMIZED);


/* See if the hardware, software and recorder are compatible with this */
/* version of OMNIDEMO, and that the recorder initialized successfully. */
space = COMPATIBILITYOUT; /* Tell DLL the version level of this */
/* program. */
ArDllRun(ARCOMPATIBILITY, NULL, 0, 0, 0, 0, &space, &fcerr, &retval1,
&retval2);

li00tao 2003-06-20
  • 打赏
  • 举报
回复
有很多重定义阿
yes!!
web_spider 2003-06-20
  • 打赏
  • 举报
回复
我在directx中就经常出现这个问题。
系统默认的头文件版本是7.0,我现在用的是9.0的开发包,当是我也是搞不明白,
很愚昧,到后来搞好了
xiaoyupzy 2003-06-20
  • 打赏
  • 举报
回复
请问重定义是怎么回事,要怎么解决啊?
zhzc3911 2003-06-20
  • 打赏
  • 举报
回复
up
web_spider 2003-06-20
  • 打赏
  • 举报
回复
用的头文件版本不一致,你应该在option中把你的头文件放在最前面,不然他就先找默认的了
Windmoon_hz 2003-06-20
  • 打赏
  • 举报
回复
有很多重定义阿
huigll 2003-06-20
  • 打赏
  • 举报
回复
警告先不管
不过这个错误好象没有办法:
LNK1136
invalid or corrupt file

The input file either has a corrupt header or is zero size or abnormally small.

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧