Re: [問題] 為什麼作業系統都用C寫? 而不用C++呢?
回應littleshan
1.
in header file
struct FS
{
int (*remove)(const char *path);
};
#define FS(type) type##_fs
in local_fs.c
static int remove(const char *path){...}
struct FS local_fs;
local_fs.remove = remove;
in remote_fs.c
static int remove(const char *path){...}
struct FS remote_fs;
remote_fs.remove = remove;
Then you can call anywhere like,
struct FS *fsp = &FS(remote);
fsp->remove("filename");
2.
lock(r1);
if(...)
goto exit1;
lock(r2)
if(...)
goto exit2;
...
exit2:
unlock(r2);
exit1:
unlock(r1);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 115.83.188.241
※ 編輯: meltice 來自: 115.83.188.241 (03/07 20:34)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 16 之 37 篇):