📄 00000000.htm
字号:
thread with CreateThread() and my exceptionis never caught. <BR> <BR>Answer: <BR>Use _beginthread(). The function CreateThread does not <BR>initialize the RTL, which the exceptions depend on. Rumor has it <BR>that MS may initialize some RTL stuff in there DLL's. So , <BR>CreateThread() may work for them, but MS say's to use <BR>_beginthread()if you are using any "...C runtime functions..." <BR>(mentioned at the bottom of the Help file for CreateThread()). <BR>Thus, _beginthread IS the recommended function to use and we <BR>have not broken or violated anything. Not a bug !!!! <BR> <BR>10、Netscape Plug-ins SDK <BR> <BR>Question: <BR>Has any body been able to compile a DLL using the <BR>Netscape Plug-in SDK and Borland's development tools? <BR> <BR>One of the header files generates an error <BR>'CANNOT USE EXTERN "C" WITH TEMPLATES OR OVERLOADED OPERATORS' <BR>what is going on here? <BR> <BR>Answer: <BR>Certain C++ constructs cannot be wrapped in extern C <BR>because the resulting names would not be meaningful. <BR> <BR>The extern "C" wrapper should only be used around three functions <BR>in npwin.cpp. <BR> <BR>But first, ensure your .dll's name starts with np: <BR>e.g. npplugin.dll. <BR> <BR>Second, create an export section in you're .def file with three <BR>Netscape functions to set up entry points: <BR>e.g. <BR> <BR>EXPORTS <BR>NP_GetEntryPoints @1 <BR>NP_Initialize @2 <BR>NP_Shutdown @3 <BR> <BR>Finally, you need to wrap these three functions in the npwin.cpp <BR>with extern "C": <BR>e.g. <BR> <BR>extern "C" NPError WINAPI NP_EXPORT NP_GetEntryPoints(NPPluginFuncs* pFuncs) <BR>etc... <BR> <BR>A good reference that discusses how to non-MS compilers is <BR>"Programming Netscape Plug-Ins" by Zan Oliphant. <BR>ISBN 1-57721-098-3, published by Sams-Net. <BR> <BR>11、Exception Handling and VCL <BR> <BR>Question: <BR>Is there a simple way to catch exceptions in the control's <BR>events? <BR> <BR>Answer: <BR>Create a method of the form to trap for exceptions. This method <BR>will be called on the OnException method of the application. In <BR>your method, check for the exception you're looking for, <BR>ie EDatabaseError. Check the on-line help for the OnException <BR>event. It has info on how to call your own method for the event. <BR>For example: <BR> <BR> void __fastcall TForm1::MyException(TObject *Sender, Exception *E) <BR> { <BR> // Don't forget to do a forward declaration for this in the class <BR> // definition. <BR> <BR> if (dynamic_cast<EDatabaseError*> (E)) <BR> { <BR> MessageBox(0, E->Message.c_str(), "Trapped Exception", MB_OK); <BR> } <BR> else <BR> { <BR> // This is not the error you are looking for, Raise the exception. <BR> // ... <BR> } <BR> } <BR> <BR> void __fastcall TForm1::FormCreate(TObject *Sender) <BR> { <BR> Application->OnException = MyException; <BR> } <BR> <BR>12、Why can't I use a member function of an object to create a thread <BR> <BR>Question: <BR>I'm trying to spin a thread, and I want to use a member <BR>function as the thread procedure. But I can't get <BR>the compiler to accept it. Why not? <BR> <BR>Answer: <BR>C++ does not allow this behavior. <BR> <BR>Class methods are stored in memory in exactly (1) location. <BR>The way that a class method accesses other members of a <BR>class is via a pointer which is silently passed as the <BR>first argument to the method; windows knows nothing about <BR>this pointer, and is unable to pass it. <BR> <BR>The compiler will not allow you to call a non-static member <BR>function without an object because it does not know what <BR>to store in the this pointer; if it did, you would still <BR>not be happy with the result, because windows would NOT <BR>pass a this pointer as the first argument. <BR> <BR>To get around this, you can: <BR> <BR>(a) use a static method. <BR>(b) have a global c-style function which calls the method <BR>of a particular object by invoking it explicitly, eg. <BR> <BR>int foo() { <BR> object.method() <BR>} <BR> <BR>and then pass that to the thread-invocation function. <BR> <BR>13、Errno, BC5.02, and C++Builder <BR> <BR>Question: <BR>I've created this static library in BC++ 5.0, <BR>and i'm trying to use it in C++Builder, but <BR>i'm getting linker errors regarding _errno. Why? <BR>Shouldn't this be the same in both products? <BR> <BR>Answer: <BR>At first glance, it seems like it should. But <BR>if you look at the header file, you will see <BR>that _errno is _different_ depending on whether <BR>or not _MT is defined. This is because the default <BR>errno is not thread-safe, and the one provided <BR>when _MT (which determines whether the compiler <BR>should use the multi-threaded or non-multi-threaded <BR>versions of the RTL) is defined is. <BR> <BR>The defaults for this compiler define vary between <BR>BC++ 5.02 and BC++Builder. Thus, you cannot link; <BR>the symbol is different. <BR> <BR>You need to rebuild your .lib in BC++ 5.02 <BR>_with _MT defined._ <BR> <BR>14、Fatal General error in .#nn files or assert failures from ilink <BR> <BR>Question: <BR>Problems at link time <BR>Linker Fatal General error in .#nn files or assert failures from ILINK <BR> <BR>Problem description: <BR>At link time <BR>Fatal General error in module ..\lib\vcld.#02. Sometimes it is vcld.#00 or <BR>vcld.#01. <BR> <BR>Using the incremental linker the error is <BR>Fatal: Assertion failed: recLen == 0 at "IMPORT.CPP", line 486" <BR> <BR>Answer: <BR>There is a known problem that shows up when using typedefed instantiations <BR>of templates in headers with precompiled headers and debug info is turned <BR>on. The problem will show up as general failures in .#nn with the standard <BR>linker or asserts with the incremental linker. <BR> <BR>The workaround is to manage your precompiled headers with #pragma <BR>hdrstop being sure to exclude the header(s) with template typedefs <BR>from the pch. <BR> <BR>#include <vcl\vcl.h> <BR>#include "mypch.h" // headers that seldom change and no templates <BR>#pragma hdrstop <BR>#include "mytemplates.h" <BR> <BR> <BR>Note that the problem is really with the external-type OBJ, those .#nn files <BR>( -He in the readme ). So you could also just turn that switch off. <BR>Open the .MAK file and add -He- to the CFLAG1 line. <BR> <BR>-- <BR> <BR>※ 修改:·Zeemon 於 Dec 3 20:03:11 修改本文·[FROM: sapphire.ncic.a] <BR>※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: sapphire.ncic.a] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -