Minimum optimizations required to use inline functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Minimum optimizations required to use inline functions

Wayne Uroda-3
Hi,

I make extensive use of inline functions in my code, as below:

    extern inline void setClockLine(Bool value)
    { ... }

Sometimes I put these definitions in .c files, sometimes in .h files (I'm
not sure if that makes a difference, apart from scope).

The code builds and links at -O (or -O1, -O2) but does not link at -O0, I
get many linker errors like
   i2c.c:67: undefined reference to `setClockLine'

I wonder, what is/are the minimum flag(s) required to make inlining work?
If I use just these flags am I likely to get better debug experience? There
are no inline functions involved in the code I am trying to debug but I am
still having trouble stepping through the code.

I notice that newer versions of gcc have a -Og flag, does MSPGCC support
this?
I am running msp430-gcc (GCC) 4.6.3 20120301 (mspgcc LTS 20120406 unpatched)

I am using a combination of mspdebug, eclipse CDT, zylin embedded debug
native and msp430-gdb for debugging.

Thanks
Wayne

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: Minimum optimizations required to use inline functions

Peter Bigot-4
On Sat, Apr 12, 2014 at 8:43 PM, Wayne Uroda <[hidden email]> wrote:
> Hi,
>
> I make extensive use of inline functions in my code, as below:
>
>     extern inline void setClockLine(Bool value)
>     { ... }
>
> Sometimes I put these definitions in .c files, sometimes in .h files (I'm
> not sure if that makes a difference, apart from scope).

It does.  See (for example): http://m68hc11.serveftp.org/inline-1.php

This explains your linker error, assuming you don't have a
non-extern/non-inline definition in a .c file.

I generally use "static inline" definitions placed in headers.  Since
-Os can affect whether a function is actually inlined, there's also
attribute __always_inline__ that can be added to encourage the
compiler more strongly (might even be an error if it can't be
inlined).

I haven't tried -Og to see if it does anything.

Peter

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users