C LANGUAGE
oop
Object-oriented programming
C99
ring buffer
Author: CrazyMonkey
email: kccddb@gmail.com
Date: 20230214
Copyright: CC BY-NC-SA
HW. 設計一 CPolygon (多邊形)
CPolygon *init_CPolygon(int edges,…);
//計算周長
int (*Perimeter) (struct Polygon *);
int exit_CRectangle(CPolygon *pThis);
Hint:
stdarg, va_start, va_arg, va_end, va_copy - variable argument lists
當您改變 CC, CFLAGS, LDFLAGS, …等可以改變為不同 CPU, 如此以後才方便移植至其他 SoC!
ar - create, modify, and extract from archives
ranlib - generate an index to an archive
使用 gcc 自製 C/C++ 靜態、共享與動態載入函式庫教學, by G. T. Wang
Futher Reading:
-fPIC, PIC = position independent code
Ref.
Creating a shared and static library with the gnu compiler (gcc), by Alberto Fanjul (albfan).
drivers/char/misc.c
簡單但實用的 ring buffer (circular buffer, circular queue and cyclic buffer) , 請自行測試
尤其是記憶體受限時, 例如 單晶片, embedded system 或資料變動快速與大量時(使用ring buffer (fixed maximum size) 不需要 經常 malloc, free, 如此可減少 OS 進行 garbage collection! )
有次 研發人員 處理 快速大量資料時(每次大小不一定) 用 linked list, 改建議 他使用 ring buffer.