public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rwitmer at xmission dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/45082] Static const signed int class member causes undefined symbol.
Date: Tue, 27 Jul 2010 15:27:00 -0000	[thread overview]
Message-ID: <20100727152731.2605.qmail@sourceware.org> (raw)
In-Reply-To: <bug-45082-19484@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2010-07-27 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26 15:25 [Bug c++/45082] New: " rwitmer at xmission dot com
2010-07-26 15:32 ` [Bug c++/45082] " jakub at gcc dot gnu dot org
2010-07-26 15:59 ` rwitmer at xmission dot com
2010-07-26 16:33 ` redi at gcc dot gnu dot org
2010-07-26 16:37 ` redi at gcc dot gnu dot org
2010-07-27 15:27 ` rwitmer at xmission dot com [this message]
2010-07-27 23:55 ` redi at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100727152731.2605.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).