小编Ree*_*ril的帖子

Segmentation fault while using function pointer

I get a segmentation fault when I declare a function pointer before main() and assign it with the address of a function inside main. What is the actual problem that occurs if the function pointer is declared before main()??

The code is given below:

#include <stdio.h>
#include <pthread.h>

void fun1(char *str)
{
    printf("%s",str);
}

void (* funptr)(char *);

int main()
{

    char msg1[10]="Hi";
    char msg2[10]="Hello";
    pthread_t pid1, pid2;

    funptr=&fun1;

    pthread_create(&pid1,NULL,(void *)(*funptr),(void *)msg1);
    pthread_create(&pid1,NULL,(void *)(*funptr),(void *)msg2);

    pthread_join(pid1,NULL);
    pthread_join(pid2,NULL);
    return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c function-pointers segmentation-fault

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

确定 IRQL 级别

如何确定一段驱动程序代码的IRQL Level?PAGED_CODE() 宏指定该代码段可以在低于 DISPATCH_LEVEL 的 IRQL 级别上运行。但是如何确定确切的 IRQL 级别。

windows device-driver irql

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