This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45082] Static const signed int class member causes undefined symbol.
- From: "rwitmer at xmission dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jul 2010 15:27:31 -0000
- Subject: [Bug c++/45082] Static const signed int class member causes undefined symbol.
- References: <bug-45082-19484@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from rwitmer at xmission dot com 2010-07-27 15:27 -------
Thanks for all the great comments and insight.
I'm still confused as to why when the BUFF_SIZE was defined as:
static const signed int BUFF_SIZE = 20;
it caused the error, but when it was defined as:
static const unsigned int BUFF_SIZE = 20;
it did not.
void funky(const int& in) is an example of a library call I had to use, I have
no control over the author's over zealousness on using a const int& parameter.
There were 2 things that solved the problem I was seeing:
1. Adding a const signed int BUFF_SIZE; line to the .cpp file.
I've seen lots of code where we define constants ala, static const int
BUFF_SIZE=20; in the .hpp file without any const int myclass::BUFF_SIZE; in the
.cpp files. Is that wrong to exclude them, should we be including them in the
.cpp file?
2. Declaring the type during the call, ala, funky((int)myclass::BUFF_SIZE);
I'm not sure which is the better solution.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45082