This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
Is the following buggy core or a bug in 4.3? I don't see why it should fail. The problem is that when I compile an inline function with -std=gnu99, it will not be found during linking. Example: gcc -c t.c gcc -c -std=gnu99 timer.c gcc -o t t.o timer.o This results in: t.c:(.text+0x1c): undefined reference to `timerdiv' but it works when I either remove the "inline" attribute to timerdiv or the -std=gnu99. Code: timer.c: #include <sys/time.h> inline void timerdiv(struct timeval *tvp, float div) { double interval; if (div == 0 || div == 1) return; interval = ((double)tvp->tv_sec * 1000000 + tvp->tv_usec) / (double)div; tvp->tv_sec = interval / (int)1000000; tvp->tv_usec = interval - (tvp->tv_sec * 1000000); } t.c: #include <sys/time.h> struct tcpr_speed_s { float speed; }; typedef struct tcpr_speed_s tcpr_speed_t; struct tcpreplay_opt_s { tcpr_speed_t speed; }; typedef struct tcpreplay_opt_s tcpreplay_opt_t; struct timeval nap; tcpreplay_opt_t options; extern void timerdiv(struct timeval *tvp, float div); int main() { timerdiv(&nap, options.speed.speed); return 0; }
I forgot to mention that it works fine with 4.1.
Inline behavior is now C99 compatible by default, you need to use extern inline in this case.
Plain inline without any thing which says static or extern in C99 is the same as what GNU-C90 considers as their "extern inline" and not what C99 considers as "extern inline". If you add a prototype that says extern, it will just work.