This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in g++ 4.1.2 when using inline function definied in cpp file but declared in h file


We don't track bugs reported via email. If you want to make sure you get an answer, use the bugzilla database instead. This doesn't seem to be a gcc bug though.

In C++, the inline keyword is similar to what "static inline" means in GNU C, i.e. only emit the function if it is used. Since there is no use of the function in a.cpp, gcc does not emit it. You can see this if you compile a.cpp with -S and look at the assembler output.

You can fix this by deleting the use of the inline keyword. Or you can fix it by putting the inline function definition into the a.h file instead of the a.cpp file. This way it will be visible in main.cpp when we call it, and then gcc will emit it.

Or you can fix it by using pragma implementation and pragma interface as you discovered.

I'm not a C++ expert.  There may also be other ways to fix this.
--
Jim Wilson, GNU Tools Support, http://www.specifix.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]