C經典案例
阿新 • • 發佈:2018-05-22
HA list star handler va_start structure hand stc pen
1. C中可變參數函數作為函數參數:
void media_debug_set_handler(struct media_device *media, void (*debug_handler)(void *, ...), void *debug_priv) 調用: media_debug_set_handler(media, (void (*)(void *, ...))fprintf, stdout);
2.可變參數函數
gstcaps.c GstCaps *gst_caps_new_full (GstStructure * struct1, ...) { GstCaps*caps; va_list var_args; va_start (var_args, struct1); caps = gst_caps_new_full_valist (struct1, var_args); va_end (var_args); return caps; } GstCaps * gst_caps_new_full_valist (GstStructure * structure, va_list var_args) { GstCaps *caps; caps = gst_caps_new_empty (); while (structure) { gst_caps_append_structure_unchecked (caps, structure); structure= va_arg (var_args, GstStructure *); } return caps; }
C經典案例