PTT
Submit
Submit
選擇語言
正體中文
简体中文
PTT
C_and_CPP
[問題] function create的方式
作者:
cooboy
(0.0)
2016-09-27 10:12:38
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Android
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
None
問題(Question):
在網路上看到這段code 有人知道這種寫法嗎?
jpege_engine_hw_create 呼叫自己?這是要?
另外就是找不到是誰去call這個副程式 會是load library時就被呼叫嗎?
static void jpege_engine_hw_create(jpege_engine_obj_t *p_obj,
jpege_hw_obj_t encoder)
{
if (p_obj) {
// Destroy previous engine if it exists
if (p_obj->destroy) {
p_obj->destroy(p_obj);
}
p_obj->create = &jpege_engine_hw_create;
p_obj->init = &jpege_engine_hw_init;
p_obj->check_start_param = &jpege_engine_hw_check_start_param;
p_obj->start = &jpege_engine_hw_start;
p_obj->abort = &jpege_engine_hw_abort;
p_obj->destroy = &jpege_engine_hw_destroy;
p_obj->p_engine = NULL;
p_obj->encoder = encoder;
p_obj->is_initialized = false;
}
}
補充說明(Supplement):
code來源:
https://goo.gl/UoNaJ2
作者:
LPH66
(-6.2598534e+18f)
2016-09-27 10:23:00
關鍵字: 函式指標
作者: LiloHuang (十年一刻)
2016-09-27 10:31:00
這是用 C 寫 OO 的做法,把 p_obj 想成 this 指標就是可以看看 Axel Schreiner 寫的
https://goo.gl/WrD6Kc
作者:
kevingwn
(如雲如風的人生)
2016-09-27 11:04:00
從jpege.c 1465行來看 p_obj->create是用來做檢查的不會用來呼叫
繼續閱讀
Re: Visual Studio 與C問題
pttworld
Visual Studio 與C問題
Vinxer
[問題] 組合模式(Composite Pattern)到底是什麼
henry8168
Re: [問題] QT DESIGER產生CODE的地方
Serge45
[問題]跪求C語言三維動態陣列?????
hunkchen2000
[問題] 用dev c++ 算函數執行時間都是0
PINKs
[問題]請問C語言二為動態陣列輸入字串
hunkchen2000
Makefile讀檔問題
cyysh4164
[問題] QT DESIGER產生CODE的地方
MOONY135
[問題] C語言字串擴張合併 記憶體管理問題
deo2000
Links
booklink
Contact Us: admin [ a t ] ucptt.com