小编Ste*_*end的帖子

链接器以哪种顺序处理库目录?

编译期间,搜索路径中可能存在多个库实例.链接器处理目录以什么顺序包含在搜索路径中?有问题的平台是Sun OS.

c++ linker sunos

6
推荐指数
1
解决办法
2859
查看次数

如何使用Python将FIX登录消息发送到GDAX/Coinbase

我正在尝试为fix.gdax.com建立一个FIX 4.2会话(docs:https://docs.gdax.com/#fix-api 或https://docs.prime.coinbase.com/?python#logon -a)使用Python 3.5和stunnel.除了我的登录消息之外,一切都正在工作,该消息被拒绝,服务器关闭会话而没有响应,因此很难调试出错的地方.我的Python代码如下:

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 4197)) # address and port specified in stunnel config file

# generate a signature according to the gdax protocol for signing a message:
timestamp = str(time.time())
message   = [timestamp, "A", "0", "f3e85389ffb809650c367d42b37e0a80", "Coinbase", "password-goes-here"] # these are the components of the pre-hash string as specified in the docs for a logon message
message   = bytes("|".join(message), 'utf-8') # add the field separator

hmac_key  = base64.b64decode(r"api-secret-goes-here")
signature = …
Run Code Online (Sandbox Code Playgroud)

python fix-protocol coinbase-api gdax-api

6
推荐指数
1
解决办法
2338
查看次数

.NET 4中是否存在二进制搜索树实现?

我正在寻找.NET 4中的内置二进制搜索树实现.有一个吗?

.net binary-tree .net-4.0 data-structures

5
推荐指数
1
解决办法
491
查看次数

如何在C++ .net中将gcroot <Object ^>转换为IMyInterface?

我不得不用gcroot做一些奇怪的事情,但我在动态转换线上得到以下错误:"不能使用'dynamic_cast'从'gcroot'转换为'IMyInterface ^'.在C#中,你可以很容易地投出一个任何接口的泛型对象.如果对象没有实现接口但是它会编译,你可能会遇到运行时错误.

gcroot<Object^> m_pDataObject;
IMyInterface obj = dynamic_cast<IMyInterface^>(m_pDataObject);
Run Code Online (Sandbox Code Playgroud)

.net casting c++-cli visual-c++

5
推荐指数
2
解决办法
2757
查看次数

Linux中的Windows命名管道支持

我正在研究一个项目,该项目需要使用命名管道的传统Windows应用程序与在Linux服务器上运行的新服务之间进行进程间通信.Windows应用程序无法更改.有谁知道是否有可用的Linux库支持Windows命名管道?或者甚至更好,有人可以推荐他们用于此目的的图书馆吗?

c++ linux windows network-programming named-pipes

5
推荐指数
1
解决办法
3757
查看次数

将boost :: unordered_set作为结果映射传递给boost :: split

有没有人知道如果将boost :: unordered_set作为boost :: split的第一个参数传递是犹太洁食?在libboost1.42-dev下,这似乎会导致问题.这是一个导致问题的小例子程序,称之为test-split.cc:

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/unordered_set.hpp>
#include <string>

int main(int argc, char **argv) {
  boost::unordered_set<std::string> tags_set;
  boost::split(tags_set, "a^b^c^",
               boost::is_any_of(std::string(1, '^')));
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

然后,如果我运行以下命令:

g++ -o test-split test-split.cc; valgrind ./test-split
Run Code Online (Sandbox Code Playgroud)

我在valgrind中得到了一堆投诉,就像下面那样(我有时也看到没有valgrind的coredump,虽然它似乎根据时间而变化):

==16843== Invalid read of size 8
==16843==    at 0x4ED07D3: std::string::end() const (in /usr/lib/libstdc++.so.6.0.13)
==16843==    by 0x401EE2: unsigned long boost::hash_value<char, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /tmp/test-split)
...
==16843==    by 0x402248: boost::unordered_set<std::string, boost::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> >& boost::algorithm::split<boost::unordered_set<std::string, boost::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> >, char const [26], …
Run Code Online (Sandbox Code Playgroud)

c++ boost split unordered-set c++11

5
推荐指数
1
解决办法
1187
查看次数

在STL图的不相交子范围上计算平均值的有效方法

我正在将算法从C#转换为C++.该算法的一小部分是计算字典中某些区域的平均值.

字典中的数据按以下方式存储:

Index     Value
1         10
3         28
290       78
1110      90
Run Code Online (Sandbox Code Playgroud)

我需要计算索引小于某个数字的所有值的平均值,并且所有索引值都大于某个数字.在C#中我按以下方式执行:

if (dictionary.Where(x => x.Key < areaWidth).Count() > 0)
{
    avgValue = (int) dictionary.Where(x => x.Key < areaWidth).Average(
        x => x.Value);
}

for (var i = 0; i < line.Length; i++)
{
    if (i == areaWidth)
    {
        avgValue = -1;
        i = line.Length - areaWidth;
        var rightBorder = i - areaWidth;

        if (dictionary.Where(x => x.Key > (rightBorder)).Count() > 0)
        {
            avgValue = (int) dictionary.Where(
                x => x.Key > …
Run Code Online (Sandbox Code Playgroud)

c++ stl average map

5
推荐指数
1
解决办法
2551
查看次数

5
推荐指数
2
解决办法
130
查看次数

查找仅在优化构建中显示的C程序中的错误的最佳实践是什么

我的程序使用第三部分库,在某些时候抛出分段错误.我尝试用调试符号编译库,没有编译器优化,崩溃消失了.我怀疑是编译器优化揭示了这个错误.调试此类案例的最佳做法是什么?

编辑 - (纠正上述声明:"显示"而不是"引起")

我想我被误解了.我没有打算责怪编译器,或类似的东西.我只询问了在这种情况下找到错误的最佳实践,我在第三方库中没有调试符号(崩溃回溯导致第三方库).

c debugging gdb

5
推荐指数
2
解决办法
634
查看次数

奇怪的"内存泄漏检测"错误C++

我有一个非常奇怪的内存泄漏问题.我使用_CrtDumpMemoryLeaks来检查泄漏.这是我的WinMain功能:

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    ////////////////// SET UP CHECKS FOR MEMORY LEAKS ////////////////////
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    //////////////////////////////////////////////////////////////////////


    _CrtDumpMemoryLeaks(); // Reports leaks to stderr

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我已经完全删除了所有内容,只是为了检查是否有某种误报.

关闭应用程序后,我在输出中得到了这堆内存泄漏:

Detected memory leaks!
Dumping objects ->
{1343} normal block at 0x06076780, 8 bytes long.
 Data: < g      > 20 67 07 06 00 00 00 00 
{1342} normal block at 0x06076710, 52 bytes long.
 Data: <@   @ …
Run Code Online (Sandbox Code Playgroud)

c++ memory memory-leaks visual-c++

5
推荐指数
1
解决办法
362
查看次数