简体   繁体   English

C++ API 未处理异常:Microsoft C++ 异常:std::bad_alloc

[英]C++ API unhandled exception: Microsoft C++ exception: std::bad_alloc

In VS2019 (C++ API ), the same code completed under Release compiling but raised an error under DEBUG compiling.在 VS2019 (C++ API) 中,相同的代码在 Release 编译下完成,但在 DEBUG 编译下引发错误。

The code is as below:代码如下:

#include "include\DolphinDB.h"
#include "include\Util.h"
#include <iostream>
#include <string>

using namespace dolphindb;
using namespace std;

int main(int argc, char* argv[]) {

    string host = "192.168.2.114";
    int port = 8848;
    string username = "admin";
    string password = "123456";
    DBConnection conn;
    ConstantSP vector;
    int size=0;

    std::cout << "Connecting DolphinDB: [" << host << ":" << port << "]  Username:[" << username << "] Password:[" << password << "]" << endl;
    bool ret = conn.connect(host, port,username,password);
    if (!ret) {
        cout << "Failed to connect to the server" << endl;
        //getchar();
        //return 0;
        goto END_APP;
    }
    else
    {
        cout << "Had connected to DolphinDB server [" << host << ":" << port << "] Username=["<<username<<"]\n";
    }
    //ConstantSP vector = conn.run("`IBM`GOOG`YHOO");
    vector = conn.run("today();now()");
    size = vector->rows();
    for (int i = 0; i < size; ++i)
        cout << vector->getString(i) << endl;

END_APP: getchar();
    return 0;
}

The error is as follows:错误如下:

unhandled exception: Microsoft C++ exception: std::bad_alloc, located at memory 0x000000B29C97EE30.未处理的异常:Microsoft C++ 异常:std::bad_alloc,位于内存 0x000000B29C97EE30。

The library used now is the release version.现在使用的库是发布版本。 If the project uses debug, the library also needs to be compiled with the debug version.如果项目使用debug,库也需要用debug版本编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM