Just started learning to program in Windows, but I am having a wierd error.

This is a discussion on Just started learning to program in Windows, but I am having a wierd error. within the Windows Programming forums, part of the Platform Specific Boards category; I think it is a problem with my compiler (Visual Studio .NET), it says: fatal error C1010: unexpected end of ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    Just started learning to program in Windows, but I am having a wierd error.

    I think it is a problem with my compiler (Visual Studio .NET), it says:

    fatal error C1010: unexpected end of file while looking for precompiled header directive

    and here is my code:
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    #define CLASS_NAME "Mi Ventana"
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    	HWND hwnd;
    	MSG msg;
    	WNDCLASSEX wndclass;
    
    	wndclass.cbSize = sizeof (wndclass);
    	wndclass.style = CS_HREDRAW | CS_VREDRAW;
    	wndclass.lpfnWndProc = WndProc;
    	wndclass.cbClsExtra = 0;
    	wndclass.cbWndExtra = 0;
    	wndclass.hInstance = hInstance;
    	wndclass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
    	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    	wndclass.lpszMenuName = NULL;
    	wndclass.lpszClassName = CLASS_NAME;
    	wndclass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    
    	RegisterClassEx(&wndclass);
    
    	hwnd = CreateWindow(CLASS_NAME, "Ventana 1", WS_OVERLAPPEDWINDOW, 100, 100, 500, 500, NULL, NULL, hInstance, NULL);
    
    	ShowWindow(hwnd, iCmdShow);
    	UpdateWindow(hwnd);
    
    	while (GetMessage(&msg, NULL, 0, 0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	UnregisterClass(CLASS_NAME, hInstance);
    
    	return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (iMsg)
    	{
    
    	case WM_CLOSE:
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
    	}
    
    	return DefWindowProc(hwnd, iMsg, wParam, lParam);
    }
    anyone knows what is the problem?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    skim thru your project options and turn off precompiled headers. Then try building again.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Thanks for youre help but I did not find that option, and now I am sure it is not a problem with the code, I get that same error even with tutorials and sample codes I dowloaded, so I am just going to re-install the whole thing.
    Why drink and drive when you can smoke and fly?

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> Thanks for youre help but I did not find that option

    Project -> Settings -> C/C++ tab -> Precompiled Headers in the Category list box.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    The only "problem" i can see with your code from a quick skim thru is that you use LoadIcon for the WNDCLASSEX::hIconSm. LoadIcon() if you look at the documentation is not guaranteed to work on anything other than icons of size defined by GetSystemMetrics(SM_CXICON) by GetSystemMetrics(SM_CYICON). This commonly does in fact appear to work but the documentation suggests that you use LoadImage() instead.
    Your problems should go away when you work out how to turn precompiled headers off.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Thank you all for youre help, I dont know what the problem was but I re-insalled my compiler and the exact same code works perfectly O_O
    Why drink and drive when you can smoke and fly?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21