I'm recently taking Operating System course, where we study xv6. During practice lab I ran into the code like below:
// xv6_public/syscall.c
#include "defs.h"
#include "syscalls.h"
...
extern int sys_fork(void);
...
static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
...
};
I didn't recognize the syntax used above at all at first. After searching the net I found that the syntax is called Lambda function, but I still have questions:
- Many articles say it is available to use Lambda only with C++. Is it able to use Lambda in C? Is syntax the same as that of C++? (the source files are all
.c
, probably compiler is g++) - Would someone briefly explain the code above? I can understand that it is function pointer array where each element is lambda function. Or please recommend nice reference to read.