[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] inline vs. #define

From: Geoffrey Wossum
Subject: Re: [avr-gcc-list] inline vs. #define
Date: Wed, 26 Mar 2003 09:39:11 -0600
User-agent: KMail/1.5

On Wednesday 26 March 2003 09:23 am, David Brown wrote:

> > the gcc manual somewhere.  I'm guessing it's the same effect as far as
> > generated code, but it seems like "static inline" would cause extraneous
> > warnings.  If you had a "static inline" in a header file, included it in
> > a source file, and never called the function, then I would expect the

> Do you mean something like:
> /* utils.h */
> extern inline int square(int n);
> /* utils.c */
> #include "utils.h"
> inline int square(int n) { return n*n; }
> int test(int x) { return square(x); }            /* square is inlined */
> /* main.c */
> #include "utils.h"
> int test2(int x) { return square(x); }          /* square is a normal
> extern funciton */

No, change utils.h to be:

extern inline int square(int n) {
    return n * n;

and remove the square() definition from utils.c

This requires you to compile with at least -O0.  I know that there's some 
stuff in the Linux kernel which is "extern inline", especially the I/O bus 
access on x86.  Programs using direct I/O access with Linux must be compiled 
with at least -O0.

Geoffrey Wossum
Software Engineer
Long Range Systems - http://www.pager.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]