好的,这是一个愚蠢的问题.但是如何在cygwin中设置正确的根目录?这是应该在安装时完成的吗?它应设置为d:\ cygwin但当前它指向c:\并且由于该\ bin,\ etc和其他文件夹不存在.谢谢.
编辑:看起来rootdir的注册表项在版本之间已经改变了几次(我假设).在工作框中,我在"HKLM\SOFTWARE\Wow6432Node\Cygwin\setup \"键"rootdir"中指向rootdir.在非工作盒子上,我有完全不同的路径:"HKLM\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 /"和键"native",值为"d:\ cygwin".
我想我现在会放弃.感谢下面试图帮助的人们.
我将用代码说明我的问题:
#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指针然后引用?期待这个工作我错了吗?谢谢!