Problem with #pragma

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with #pragma

644 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Fri Mar 12 11:13:41 MST 2010
[SIZE=4]I want to debug a piece of code that has many timing constraints. I would like to optimize specific functions but leave others not optimized while I debug it.[/SIZE]

[SIZE=4]It seems [B][COLOR=#7f0055][COLOR=#7f0055]#pragma[/COLOR][/COLOR][/B] GCC option ([COLOR=#2a00ff][COLOR=#2a00ff]"-O3"[/COLOR][/COLOR]) would be perfect for this. However the compiler gives this warning;[/SIZE]

[SIZE=2][SIZE=2][SIZE=4]warning: ignoring #pragma GCC optimize[/SIZE]

[SIZE=4]In fact any #pragma gets ignored. What am I doing wrong?[/SIZE]

[SIZE=4]Thanks,[/SIZE]
[SIZE=4]Pete.[/SIZE]
[/SIZE][/SIZE]
0 Kudos
4 Replies

554 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Mar 12 16:12:51 MST 2010
Our evaluation of the gcc 4.4.1 / codesourcery 2009q3 indicated that, in many test cases, code size increases with the later compiler. Thus as code size is of primary importance to many customers, we have stayed with 4.3.3 for the moment.

We continue to evaluate new gcc builds, and it is likely that at some point we will update to shipping a more recent version. I cannot give any timescales as to when this might be though.

Theoretically of course, you can plug a different version of gcc into the lpcxpresso ide environment if you wish. But it may be simpler, as previously suggested, to just split the function you want to optimise differently to the rest of your code into its own file. The below knowledgebase entry gives details on using per-file properties:

  http://lpcxpresso.code-red-tech.com/LPCXpresso/node/33

Regards,
CodeRedSupport
0 Kudos

554 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Fri Mar 12 14:13:28 MST 2010
[SIZE=4]Is there any reason to not get the latest version which is 4.4.1 from Code Sourcery?[/SIZE]
0 Kudos

554 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wrighflyer on Fri Mar 12 13:41:49 MST 2010
So just put the functions that need a different optimisation level in a single .c file and arrange for only that one to be compiled with the different -O option
0 Kudos

554 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Mar 12 12:23:15 MST 2010
The `#pragma GCC optimize' pragma  is not implemented in GCC versions earlier than 4.4. LPCXpresso uses 4.3.3.

You can use function attributes to set various attributes, although, again, optimize is not supported in this version.
0 Kudos