開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
N/A
問題(Question):
typedef struct _AAA{
int a;
int b;
int c;
}AAA_T;
AAA_T aaa_db[10];
想請教板上各位先進
在function裡面
對於global structure以下兩種access aaa_db的方式
在執行效率是否有什麼不同?
如果考慮執行過程中有可能會被更高priority的ISR插斷
是否有哪一種做法較好呢?
Method 1 :
void test1(uint8 idx)
{
AAA_T *aaa_db_p = &aaa_db[idx];
aaa_db_p->a++;
aaa_db_p->b++;
aaa_db_p->c++;
}
Method 2 :
void test2(uint8 idx)
{
aaa_db[idx].a++;
aaa_db[idx].b++;
aaa_db[idx].c++;
}
感謝感謝