Thread: bcc 5.5 Declaration terminated incorrectly

  1. #1
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223

    bcc 5.5 Declaration terminated incorrectly

    I am trying to compile an example from Petzold's Programming Windows and am getting the error: "Error E2040 hexcalc\hexcalc.dlg 1: Declaration terminated incorrectly". I thought the examples should just work. I have attached the files copied straight out of the book (note rename the .txt file to .dlg). I haven't used bcc very often and have not had this error before.
    I am using Borland C++ 5.5.1.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Borland compilers shouldn't need <windows.h> #included in the resource script(*.dlg file).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Sorry, this is not what is causing it, adding/removing this line does not affect whether the program compiles or not. Removing the comment on the first few lines gives me a different error: "Error E2141 hexcalc\hexcalc.dlg 1: Declaration syntax error". Comments should not affect program compilation, why would a different error come up? Also changing the two -1s to 0 does not affect the compile. Am pretty sure that the compiler does not like the line, but I have no idea what is wrong with it:
    Code:
    HexCalc DIALOG -1, -1, 102, 122
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    //LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

    You'll want to uncomment that for this:

    wndclass.lpfnWndProc = WndProc;

  5. #5
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Quote Originally Posted by robwhit View Post
    //LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
    You'll want to uncomment that for this:
    wndclass.lpfnWndProc = WndProc;
    I thought that too at first, but un-commenting gives me this:
    Code:
    Error E2141 hexcalc\hexcalc.dlg 2: Declaration syntax error
    Error E2451 hexcalc\hexcalc.c 19: Undefined symbol 'WndProc' in function WinMain
    Warning W8057 hexcalc\hexcalc.c 46: Parameter 'hPrevInstance' is never used in function WinMain
    Warning W8057 hexcalc\hexcalc.c 46: Parameter 'szCmdLine' is never used in function WinMain
    Warning W8060 hexcalc\hexcalc.c 93: Possibly incorrect assignment in function WndProc
    Warning W8084 hexcalc\hexcalc.c 123: Suggest parentheses to clarify precedence in function WndProc
    *** 2 errors in Compile ***
    Whereas I just get the first warning when I comment the line out.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    *---------------------------
       HEXCALC.DLG dialog script
      ---------------------------*/
    You're missing a /.

  7. #7
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Quote Originally Posted by robwhit View Post
    [CODE]You're missing a /.
    Thanks for pointing that out, that happened mainly due to using notepad and was the direct result of copy>paste.
    Fixing that, I get:
    Code:
    Error E2141 hexcalc\hexcalc.dlg 6: Declaration syntax error
    *** 1 errors in Compile ***
    I have tried replacing the brackets with BEGIN and END but that doesn't change the error, nor does commenting out the CLASS and/or caption lines. Also the windows.h doesn't need to be included.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Petzold's Programming Windows ... I thought the examples should just work
    Petzold uses a microsoft compiler and the examples are old. Borland's bcc5.5.1 is also old; consider getting something more recent if that's an option for you.

    That aside, with the #inclusion of the resource script in the source code file, bcc32 (bcc551's compiler) is trying and failing to parse it; it needs to be compiled separately to a resource object with brcc32(the resource compiler) and linked with the compiled source object.

    In short, remove the #include "hexcalc.dlg" line and follow the other advice already given in this thread: ensure that WndProc is forward declared, fix the comment and remove #include <windows.h> from hexcalc.dlg. Then compile the resource script with brcc32, compile the hexcalc.c with brc32 and link the objects with ilink32 using appropriate flags as described in the documentation. eg compile corrected resource:
    Code:
    brcc32 -fo hexcalc.res hexcalc.dlg
    then compile modified source:
    Code:
    bcc32 -c hexcalc.c
    and complete by linking compiled objects into final executable:
    Code:
    ilink32 -aa c0w32.obj hexcalc.obj,hexcalc.exe,,import32.lib cw32.lib,,hexcalc.res
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223

    Solved

    Wow, thanks it worked perfectly. The whole point of this program was learning how to use bcc32 as an alternative to lcc-Win32 and Dev-C++. I still get one error despite it compiling fine:
    Code:
    Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ
    Ihad not heard of ilink32 and brcc32 (I thought you had made a typo). I will still (and probably only) use this compiler for single file programs (definitely not for large files as linking is hell). Thanks again.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Ihad not heard of ilink32
    Strange, given that the readme.txt that installs with the command line tools requires you to create an ilink32.cfg file. Have you seen this faq, by the way? Also, the documentation provided with the command line tools, while sparse, is thorough and contains full information regarding each of the tools and options available for their use.

    Quote Originally Posted by error
    C0X32.OBJ
    That's for console applications, I think; c0w32.obj is for gui applications.

    For multi-file projects, using a makefile simplifies building (there's a 'make' help file, too, with the tools).
    The whole point of this program was learning how to use bcc32
    Good luck with that.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM