simple "#define" error

This is a discussion on simple "#define" error within the Windows Programming forums, part of the Platform Specific Boards category; hi, i star to learn win32, know im in the menu creation topic with resource files, i come from a ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    113

    simple "#define" error

    hi,
    i star to learn win32, know im in the menu creation topic with resource files, i come from a c++ background, so i think my problem is that im not using the #defines rigth,

    Code:
    //winmain file
    
    #include <windows.h>
    
    //my definitions file
    #include "ids.h"
    
    int WINAPI WinMain (......
    {
    
    ......
    }
    the definitions file:
    ids.h
    Code:
    #define CM_PRUEBA 100
    #define CM_SALIR 101
    the resource file
    myres.rc
    Code:
    #include "ids.h"
    
    //a simple menu with 2 items
    Menu MENU
    BEGIN
       POPUP "&Principal"
        BEGIN
           MENUITEM "&Prueba", CM_PRUEBA
           MENUITEM SEPARATOR
           MENUITEM "&Salir", CM_SALIR
        END
    END

    ok heres the error,
    I'm using vc++ 6.0

    C:\programas win32\menus4_con_archivo_RECURSO_PERSONAL\ids.h(2) : fatal error RC1004: unexpected end of file found

    if i remove in the rc file the #include"ids.h" and use
    Code:
    #define CM_PRUEBA 100
    #define CM_SALIR 101
    
    Menu MENU
    BEGIN
    	POPUP "&Principal"
    		BEGIN
    			MENUITEM "&Prueba", CM_PRUEBA
    			MENUITEM SEPARATOR
    			MENUITEM "&Salir", CM_SALIR
    		END
    END
    everything works fine, any idead what am i doing wrong?
    thanks for any help and please excuse my poor english

  2. #2
    C Programmer Stack Overflow's Avatar
    Join Date
    Apr 2004
    Posts
    477
    Hello,

    Your header file and resource file seem to be fine. When I run into errors such as "fatal error RC1004: unexpected end of file found", it usually means only one thing. This error can be caused by omitting the linefeed and carriage return characters on the last line of a text file.

    The resource compiler generates the following errors when the .RC file includes a .H file whose last line is a define (that is, there was no final carriage return at the end of the #define statement).

    Why? The resource compiler preprocessor follows C syntax. A newline character is required on a #define statement.

    How to fix it: Add a carriage return following the #define.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    113
    you mean a simple enter or a '\n'?
    thanks for reply

  4. #4
    C Programmer Stack Overflow's Avatar
    Join Date
    Apr 2004
    Posts
    477
    By carriage return, I mean't adding an actual enter in your header file.

    If you can see the difference, here is your current header ids.h:
    Code:
    #define CM_PRUEBA 100
    #define CM_SALIR 101
    And here is the new one:
    Code:
    #define CM_PRUEBA 100
    #define CM_SALIR 101
    
    // New line above [Carriage return]
    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  5. #5
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Pressing enter! like


    this...

    //edit: post beated

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    113
    hehe, i feel dumb

    thanks a lot for yer help know my code works fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

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