小编use*_*606的帖子

如何设置cygwin根目录?

好的,这是一个愚蠢的问题.但是如何在cygwin中设置正确的根目录?这是应该在安装时完成的吗?它应设置为d:\ cygwin但当前它指向c:\并且由于该\ bin,\ etc和其他文件夹不存在.谢谢.

编辑:看起来rootdir的注册表项在版本之间已经改变了几次(我假设).在工作框中,我在"HKLM\SOFTWARE\Wow6432Node\Cygwin\setup \"键"rootdir"中指向rootdir.在非工作盒子上,我有完全不同的路径:"HKLM\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 /"和键"native",值为"d:\ cygwin".

我想我现在会放弃.感谢下面试图帮助的人们.

cygwin

10
推荐指数
3
解决办法
2万
查看次数

为什么没有从指针到const指针的引用的隐式转换

我将用代码说明我的问题:

#include <iostream>

void PrintInt(const unsigned char*& ptr)
{
    int data = 0;
    ::memcpy(&data, ptr, sizeof(data));
    // advance the pointer reference.
    ptr += sizeof(data);
    std::cout << std::hex << data << " " << std::endl;
}

int main(int, char**)
{
    unsigned char buffer[] = { 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, };

    /* const */ unsigned char* ptr = buffer;

    PrintInt(ptr);  // error C2664: ...
    PrintInt(ptr);  // error C2664: ...    

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

当我运行此代码时(在VS2008中)我得到了这个:错误C2664:'PrintInt':无法将参数1从'unsigned char*'转换为'const unsigned char*&'.如果我取消注释"const"注释它可以正常工作.

但是不应该指针隐式转换成const指针然后引用?期待这个工作我错了吗?谢谢!

c++ pointers reference

9
推荐指数
2
解决办法
8091
查看次数

标签 统计

c++ ×1

cygwin ×1

pointers ×1

reference ×1