当我使用函数指针将地址从另一个文件传递给静态函数时收到分段错误

问题描述 投票:0回答:1

//文件A.c//非静态函数,全局变量

struct_type a ; 
void func()
{
    int b = 10;
    func_ptr(b, &a); 
}

//文件B.c// static func,global func ptr

void *func_ptr(int, *struct_type); 

static void static_func(int val, struct_type *data)
{
    //defn
    func_ptr = &static_func;
}

接收到的分段错误

c segmentation-fault pass-by-reference static-functions
1个回答
0
投票

C中的静态函数是范围仅限于其目标文件的函数。

© www.soinside.com 2019 - 2024. All rights reserved.