Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!aero-c!gumby.dsd.trw.com!deneva!wiley!rich From: rich@wiley.uucp (Rich Messenger) Newsgroups: comp.windows.ms.programmer Subject: Solution to BC++ Petzold problem, and mild bug report Message-ID: <2828D392.40DD@wilbur.coyote.trw.com> Date: 9 May 91 04:44:02 GMT Sender: news@wilbur.coyote.trw.com (News Software) Organization: TRW Inc., Redondo Beach, CA Lines: 34 I recently posted a question about wierd behavior trying to get Petzold's first sample program from _Programming Windows_ to run under BC++. Although there were no reposnses from this news group, I eventually tracked down the problem and thought I might be of general interest to other BC++ users. (1) When you are compiling as C++, you *cannot* use the EXPORTS section in the .DEF file, since the name is mangled by C++ before the linker ever sees it. This tidbit is not mentioned in the documentation. (2) You can use "smart callbacks" and thigs work great as long as you're not writing a DLL or using the huge memory model. (3) You can tag exportable functions with "_export". You *must* put this keyword in both the function declaration and function definition. MILD BUG: BC++ does not complain if you declare the function without _export, and define it with _export; it simply exhibits wierd behavior on execution. Example of bad code which BC++ does not complain about but which causes erroneous execution: long FAR PASCAL WndProc(HWND, WORD, WORD, LONG); ...definition of WinMain()... long FAR PASCAL _export WndProc(HWND hwnd, ... Hope this helps the next guy who naively tries to type in the Petzold examples straight from the book but uses C++ instead of C. _ __ ' ) ) / ... Rich Messenger /--' o _. /_ rich@wilbur.coyote.trw.com / \_(_(__/ /_ {uunet,cit-vax,trwrb}!wiley!rich