我已经完成了试图让一个较旧的程序在Vista/Win7下运行的任务。
代码看起来像C代码,但 “奇怪”编译较旧的c代码
了foo.h:
int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
long CALLBACK __export MainWndProc(HWND, UINT, WPARAM, LPARAM);
foo.c的:
int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
HANDLE hInstance; /* current instance */
HANDLE hPrevInstance; /* previous instance */
LPSTR lpCmdLine; /* command line */
int nCmdShow; /* show-window type (open/icon) */
{
/* rest of the code follows here */
我的C的知识是有限的,这句法不看起来像我见过的任何事物。 该方案已经在WinXP下运行,但不会在Vista/Win7的 - 我怀疑16位编译(这是是老......)
代码带有一个补充文件,该文件规定:
# Microsoft Visual C++ generated build script - Do not modify
...
但无论是VS2010,也没有GCC似乎可以编译这段代码(不是我试了一下,反正路上...) 使用VS2010,一个空的解决方案(VC++)第一个错误是:
error C2061: Syntaxerror: Identifier: 'MainWndProc' in line 4 of foo.h
error C2059: Syntaxerror: ';' in line 4 of foo.h
error C2059: Syntaxerror: 'Type' in line 4 of foo.h
有没有一种简单的方法可以在Win7/64bit上编译?
你可以告诉我们初学者的错误信息。 – cnicutar 2011-06-10 11:41:40
这实际上取决于你得到的编译错误,以及生成makefile的编译器。我们需要更多信息来回答这个问题。 – 2011-06-10 11:43:25
使用dev-C++我得到的代码可以通过注释foo.h中的第一行和最后一行进行编译 - 这两个函数都是(现在显然)已经在winbase.h中声明了感谢您的帮助esp。指出这是完全有效的c代码。 – Nils 2011-06-10 14:19:01