[Bug c++/30583] [ODR] Non-static inline functions cause bugs when defined more than once in different files

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Sun Feb 11 04:11:00 GMT 2007



------- Comment #2 from bangerth at dealii dot org  2007-02-11 04:11 -------
As Andrew said: this is a violation of the C++ standard. You can have
only one definition of a name and if you have more then your program is
in error. The fact that you mark your functions inline doesn't change
this: inline is an *indication* to the compiler that it should inline
the function, but it doesn't have to actually do it.

What you want to do in your case is to mark your functions as 'static'.
This way, they are local to each object file and in that case it is
completely legal to have multiple functions with the same name.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30583



More information about the Gcc-bugs mailing list