C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-24-2008, 06:26 PM   #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.
Attached Files
File Type: c hexcalc.c (4.6 KB, 66 views)
File Type: txt hexcalc.txt (1.6 KB, 76 views)
__________________
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);
P4R4N01D is offline   Reply With Quote
Old 05-24-2008, 06:47 PM   #2
erstwhile
 
Join Date: Jan 2002
Posts: 2,223
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.
Ken Fitlike is offline   Reply With Quote
Old 05-24-2008, 09:04 PM   #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);
P4R4N01D is offline   Reply With Quote
Old 05-24-2008, 10:34 PM   #4
Registered User
 
Join Date: Oct 2001
Posts: 2,110
//LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

You'll want to uncomment that for this:

wndclass.lpfnWndProc = WndProc;
robwhit is offline   Reply With Quote
Old 05-24-2008, 11:29 PM   #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);
P4R4N01D is offline   Reply With Quote
Old 05-25-2008, 11:33 AM   #6
Registered User
 
Join Date: Oct 2001
Posts: 2,110
Code:
*---------------------------
   HEXCALC.DLG dialog script
  ---------------------------*/
You're missing a /.
robwhit is offline   Reply With Quote
Old 05-26-2008, 01:48 AM   #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);
P4R4N01D is offline   Reply With Quote
Old 05-26-2008, 07:27 PM   #8
erstwhile
 
Join Date: Jan 2002
Posts: 2,223
Quote:
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.
Ken Fitlike is offline   Reply With Quote
Old 05-27-2008, 02:13 AM   #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);
P4R4N01D is offline   Reply With Quote
Old 05-28-2008, 04:45 PM   #10
erstwhile
 
Join Date: Jan 2002
Posts: 2,223
Quote:
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).
Quote:
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.
Ken Fitlike is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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