[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"Ignoring second definition" warning
From: |
mrstephengross |
Subject: |
"Ignoring second definition" warning |
Date: |
23 Sep 2005 08:02:50 -0700 |
User-agent: |
G2/0.2 |
I'm using gcc 3.3.1 on an alpha/tru64 (v5) system. When archiving
together two object files that included the same header, I run into the
archiver warning "Ignoring second definition." Consider the following
code:
=======================================
temp.h: inline int foo() { return 0; }
a.cpp: #include "temp.h"
int a() { return foo(); }
b.cpp: #include "temp.h"
int b() { return foo(); }
=======================================
I compile each .cpp into a .o :
gcc -c -o a.o a.cpp
gcc -c -o b.o b.cpp
The object files get built fine. Now I want to archive them together
into a single .a :
ar -r temp.a a.o b.o
And I get a warning about how ar is ignoring the second definition of
'foo'. It would appear that the compiler ignored the 'inline' specifier
and preserved 'foo' as a symbol in each object file.
I've tried to force gcc to truly inline the functions by playing around
with gcc's options (such as -finline-size). So far I've been
unsuccessful. Any ideas?
Thanks,
--Steve (mrstephengross@hotmail.com)
- "Ignoring second definition" warning,
mrstephengross <=