If you use our prebuilt DLLs, they are production DLLs and use the
production C++ runtime. If you compile against those you *must* use the
production runtime DLLs in your code. Otherwise, we are allocating things
in one runtime and giving them to you and you are deleting them from
another. When you compiled it as a static lib, you got around that because
its all one program and shares a static runtime.

If you want to use the debug C++ runtime, you must rebuild our stuff to use
the same.

----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
[EMAIL PROTECTED]



Born Franz <[EMAIL PROTECTED]> on 02/06/2000 08:44:24 AM

Please respond to [EMAIL PROTECTED]

To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:
Subject:  xerces 1.0.1 and VC++5.0, DLL->LIB



When trying to write my own programs with xerces and VC++5.0 I often get an
exception when an object is deleted. Seems that VC++5.0 in debugging-mode
doesn't like to free memory outside of DLL-code if it was allocated from
within the DLL. I don't face the problems with VC++6.0.

Further on I can get around this by replacing the DLL by a lib as indicated
below. But am I the only one with these problems?


Franz

---------


In Win32PlatformUtils.cpp:
void XMLPlatformUtils::platformInit()
{
    //
    //  Lets get our own DLL path and store it. The fgLibLocation static
    //  member must be filled in with the path to the shared Lib or DLL
    //  so that other code can find any files relative to it.
    //
#if !defined(BOR_LIB)
    HINSTANCE hmod = ::GetModuleHandleA(XML4C_DLLName);
    if (!hmod)
    {
        //
        //  If we didn't find it, its probably because its a development
        //  build which is built as separate DLLs, so lets look for the DLL
        //  that we are part of.
        //
        static const char* const privDLLName = "IXUTIL";
        hmod = ::GetModuleHandle(privDLLName);

        // If neither exists, then we give up
        if (!hmod)
            panic(Panic_CantFindLib);
    }

    //
    //  Get the path to our module. We explicitly get the ASCII version
here
    //  since its stored as ASCII (or the local code page to be more
specific,
    //  so it might be EBCDIC on some platforms.)
    //
    char tmpBuf[MAX_PATH + 1];
    if (!::GetModuleFileNameA(hmod, tmpBuf, MAX_PATH))
        panic(Panic_CantFindLib);

    // Find the last separator in the list and put a null in the next char
    char* sepPtr = 0;
    sepPtr = strrchr(tmpBuf, '\\');
    if (sepPtr)
        *(sepPtr+1)= 0;
    const unsigned int pathLen = strlen(tmpBuf);

    // Allocate a buffer and copy the text into it. Then store it in the
static
    char* actualBuf = new char[pathLen + 1];
    strcpy(actualBuf, tmpBuf);
    fgLibLocation = actualBuf;
#else
     fgLibLocation=".";
#endif

    //
    //  Figure out if we are on NT and save that flag for later use.
    //
    OSVERSIONINFO   OSVer;
    OSVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    ::GetVersionEx(&OSVer);
    gOnNT = (OSVer.dwPlatformId == VER_PLATFORM_WIN32_NT);

    //
    //  Ok, we have to do a little dance here to determine if we have any
    //  standard output handles. First we open up the potentially
redirected
    //  standard handles.
    //
    gStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
    gStdErr = ::GetStdHandle(STD_ERROR_HANDLE);

    //
    //  If we got the handles, then get the console mode for them. If this
    //  fails, then assume for the time being that they are just redirected
    //  files.
    //
    //  Above, when they are actually used, if they fail because of an
    //  invalid handle error, the gStdOut and gStdErr handles will get
zeroed
    //  out all further output will be eaten.
    //
    DWORD dummyParm;
    if (gStdOut)
    {
        if (!::GetConsoleMode(gStdOut, &dummyParm))
            gStdOutRedir = true;
    }

    if (gStdErr)
    {
        if (!::GetConsoleMode(gStdErr, &dummyParm))
            gStdErrRedir = true;
    }
}

and in VCPPDefs.hpp

//
---------------------------------------------------------------------------
//  A define in the build for each project is also used to control whether
//  the export keyword is from the project's viewpoint or the client's.
//  These defines provide the platform specific keywords that they need
//  to do this.
//
---------------------------------------------------------------------------
#if !defined(BOR_LIB)
#define PLATFORM_EXPORT     __declspec(dllexport)
#define PLATFORM_IMPORT     __declspec(dllimport)
#else
#define PLATFORM_EXPORT
#define PLATFORM_IMPORT
#endif






Reply via email to