小编Tro*_*ing的帖子

使内核头可供用户空间使用

我已经编写了一个自定义设备驱动程序作为树状内核模块.此设备驱动程序定义用户空间应用程序所需的一组ioctl.ioctl在自定义头文件中定义.

应该安装此头文件的标准位置是什么?应该这样/usr/include吗?或者可能是安装标准内核包含文件的位置相同?

我已阅读此问题,但它没有指定应安装自定义头文件的位置.

linux linux-device-driver linux-kernel

4
推荐指数
1
解决办法
637
查看次数

使用带浮点指针的printf会产生错误

当我尝试编译此代码时:

void main()
{
float x;
    x=6.5;
    printf("Value of x is %f, address of x %ld\n", x, &x);
}
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误:

pruebaso.c:在函数'main'中:

pruebaso.c:5:9:警告:内置函数'printf'的不兼容隐式声明[默认启用]

printf("x的值为%f,地址为x%ld \n",x和x);

^

pruebaso.c:5:9:警告:格式'%ld'需要类型为'long int'的参数,但参数3的类型为'float*'[-Wformat =]

我在另一个论坛上看到的解决方案是首先对一个无效指针进行转换:http: //www.linuxquestions.org/questions/programming-9/beginning-c-programming-how-to-print-memory-位置-printf的转换数-927305 /

但是做出这个改变,

printf("Value of x is %f, address of x %ld\n", (double)x, (void *)&x);
Run Code Online (Sandbox Code Playgroud)

现在给我一个警告:

pruebaso.c:在函数'main'中:

pruebaso.c:5:9:警告:内置函数'printf'的不兼容隐式声明[默认启用]

printf("x的值为%f,地址为x%ld \n",(double)x,(void*)&x);

^

pruebaso.c:5:9:警告:格式'%ld'需要类型为'long int'的参数,但参数3的类型为'void*'[-Wformat =]

如果有人解释我怎么能在没有得到警告的情况下解决它?

谢谢

c floating-point printf pointers

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