Which pragma should I use?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Which pragma should I use?

688 次查看
hideyuki_tokuhi
Contributor I

Hi,

I have one question about pragma in mcuxpresso‌ 

I want to prevent some lines in my source code from compiler optimization.

Which pragma should I use?

标记 (1)
0 项奖励
1 回复

619 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Hideyuki Tokuhisa,

   You can try : _attribute__((optimize("O4")))

#if ((defined __GNUC__) && (CPU_CORE == ARM_CORTEX_M))
#define SIZE_OPTIMIZATION __attribute__((optimize("O4")))
#else
#define SIZE_OPTIMIZATION
#endif


void SIZE_OPTIMIZATION testFun(void)
{
uint16_t i=0,j=0;
for(i=0;i<100;i++)
{

j=i+1;
PRINTF("j=%d",&j);
}
}

Wish it helps you!

If you still have questions about it, please kindly let me know.

Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励