瑞星卡卡安全论坛

首页 » 技术交流区 » 系统软件 » 请教
闪电风暴 - 2006-8-18 19:10:00
编译一个最简单的VC++程序,出现以下错误:
fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.

网上的方法都不管用.请各位大侠相助.

源文件:standard.cpp:
// WinStardard.cpp : Defines the entry point for the application.
//
#include <windows.h>

LRESULT WINAPI MainWndProc(HWND,UINT,WPARAM,LPARAM);
HANDLE ghInstance;
//Start WinMain
int WINAPI WinMain(HINSTANCE hInstance,
                HINSTANCE hPrevInstance,
                LPSTR lpszCmdLine,
                int nCmdShow)
{
    WHDCLASS wc;
    MSG msg;
    HWND hWnd;
    if(!hPrevInstance)
    {
        wc.lpszClassName="standardAppClass";
        wc.lpfnWndProc=MainWndProc;
        wc.style=CS_OWNDC|CS_VREDRAW|CS_HREDRAW;
        wc.hInstance=hInstance;
                wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
        wc.hCursor=LoadCursor(NULL,IDC_ARROW);
        wc.hbrbackground=(HBRUSH)(COLOR_WINDOW+1);
        wc.lpszMenuName=NULL;
        wc.cbClsExtra=0;
        wc.cbWndExtra=0;
        RegisterClass(&wc);
    }
    ghInstance=hInstance;
    hWnd=CreateWindow("standardAppClass",
                    "standard Application",
                    WS_OVERAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
                    0,
                    0,
                    CW_USERDEFAULT,
                    CW_USERDEFAULT,
                    NULL,
                    NULL,
                    hInstance,
                    NULL
                    );
    ShowWindow(hWnd,nCmdShow);
    while(GetMessage(&msg,NULL,0,0)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
        }
    return (int)msg.wParam;
}


//Funcion MainWndProc

LRESULT CALLBACK MainWndProc(HWND hWnd,UINT msg,WPARAM wParam,
                            LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hDc;
    switch(msg){
    case WM_PAINT:
        hDc-BeginPaint(hWnd,&ps);
        TextOut(hDc,10,10,"Hello,World!",13);
        EndPaint(hWnd,&ps);
        break;
    case WM_LBUTTONDOWN:
        MessageBox(NULL,"跨过长城,走向世界!","^_^,MB_OK);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return(DefWindowProc(hWnd,msg,wParam,lParam));
    }
    return 0;
}



---------------
注,如果加上#include "stdafx.h"就会返回一堆错误
天下奇才 - 2006-8-20 10:15:00
我也遇过,我是这样解决的
把相应interface文件和function文件包含到一个新的cpp文件中。在相应部分包含新的文件就解决了
闪电风暴 - 2006-8-20 13:09:00
我将另一个与之相同的CPP文件(我看起来一样,只是多了些注释)的内容复制进来,程序能成功运行.........
天下奇才 - 2006-8-20 15:54:00
引用:
【闪电风暴的贴子】我将另一个与之相同的CPP文件(我看起来一样,只是多了些注释)的内容复制进来,程序能成功运行.........
………………

在VC中,注释作用不仅仅是给程序员看的,有些注释是给编译器看的。
闪电风暴 - 2006-8-20 18:55:00
谢谢指教
1
查看完整版本: 请教