Re: [sigc] Unwanted pass-by-value behavior with MSVC++ 7.1
- From: Martin Schulze <martin-ml hippogriff de>
- To: James Lin <jameslin vmware com>
- Cc: libsigc-list gnome org
- Subject: Re: [sigc] Unwanted pass-by-value behavior with MSVC++ 7.1
- Date: Wed, 7 Jul 2004 10:40:30 +0200
Am 07.07.2004 01:17:57 schrieb(en) James Lin:
Hi,
A couple weeks ago, I posted a problem with unwanted pass-by-value
behavior I
ran into with libsigc++ 2.0.3 and MSVC++ 7.1. (I'm not sure if that
message
ever got past the moderation system.)
Hi!
I'm afraid the email you are referring to didn't reach the list.
It would be great if you submitted seperate bug reports for your issues
at bugzilla.gnome.org. I will try to catch up with the problems at the
weekend. Unfortunately, I don't have access to a MSVC system so I can't
test any changes. => Patches (against current cvs) are of course
appreciated :)
Thanks!
Martin
Basically sigc::bind somehow was causing arguments to be passed by
value even
when explicitly told to pass by reference. (I verified this by
passing
an
object by reference that had a private copy-constructor and getting a
compile-time error. Also, test_lambda was producing incorrect
results
(unrelated to the compiler optimization problem I mentioned earlier
today).)
I'm not exactly sure why, but sun_forte_workaround appears to be the
culprit.
(To get libsigc++ to compile at all with the MSVC++ 7.1 compiler, I
need to
disable the LIBSIGC_TEMPLATE_PREFIX macro. However, both
LIBSIGC_TEMPLATE_PREFIX and sun_forte_workaround are controlled by
the
existence of SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD;
disabling
LIBSIGC_TEMPLATE_PREFIX means enabling sun_forte_workaround.)
Anyhow, in adaptor_trait.h, changing:
#ifdef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES operator()
#else
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES sun_forte_workaround
#endif
to:
#if defined(SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD) \
|| defined(WIN32)
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES operator()
// ...
seems to fix my problem. I guess the comment in adaptor_trait.h is
correct:
// TODO: This should have its own test, without using operator()
#ifdef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#define LIBSIGC_TEMPLATE_PREFIX template
...
and that SIGC_WORKAROUND_OPERATOR_PARENTHESES and
LIBSIGC_TEMPLATE_PREFIX
really do need their own, independent tests.
On a related note, all of the
SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
preprocessor conditionals test only for existence, not for value. In
aclocal.m4, however, there's a line:
AC_DEFINE([SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD],[0])
I'm not familiar with m4 or with autoconf, but I assume that this
generates a
line:
#define SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD 0
which would be wrong. Shouldn't the preprocessor conditionals use
#if
FOO
instead of #ifdef FOO?
- James
_______________________________________________
libsigc-list mailing list
libsigc-list gnome org
http://mail.gnome.org/mailman/listinfo/libsigc-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]