After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 456408 - int64 and similar types cannot be used in bsewavetool.cc
int64 and similar types cannot be used in bsewavetool.cc
Status: RESOLVED FIXED
Product: beast
Classification: Other
Component: general
SVN trunk
Other Linux
: Normal normal
: m0.7
Assigned To: Beast Maintainers
Beast Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-07-12 21:59 UTC by Stefan Westerfeld
Modified: 2007-07-14 14:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch that allows using int64 in bsewavetool.cc (1.94 KB, patch)
2007-07-12 22:29 UTC, Stefan Westerfeld
none Details | Review

Description Stefan Westerfeld 2007-07-12 21:59:49 UTC
Due to double definition of int64 (SVN r4356),

  * once in sfiwrapper.h as

typedef BirnetUInt8   uint8;
typedef BirnetUInt16  uint16;
typedef BirnetUInt32  uint32;
typedef BirnetUInt64  uint64;
typedef BirnetInt8    int8;
typedef BirnetInt16   int16;
typedef BirnetInt32   int32;
typedef BirnetInt64   int64;
typedef BirnetUnichar unichar;

  * once in birnet/birnetutils.hh as

namespace Birnet {

/* --- short integer types --- */
typedef BirnetUInt8   uint8;
typedef BirnetUInt16  uint16;
typedef BirnetUInt32  uint32;
typedef BirnetUInt64  uint64;
typedef BirnetInt8    int8;
typedef BirnetInt16   int16;
typedef BirnetInt32   int32;
typedef BirnetInt64   int64;
typedef BirnetUnichar unichar;

the C++ compiler cannot which int64 to use, if you use int64 in tools/bsewavetool.cc (which is using namespace Birnet). The same is true for other types like int32 and so on. The error message looks like this:

bsewavetool.cc: In function 'int BseWaveTool::main(int, char**)':
bsewavetool.cc:95: error: reference to 'int64' is ambiguous
../sfi/sfiwrapper.h:39: error: candidates are: typedef BirnetInt64 int64
../birnet/birnetutils.hh:35: error:                 typedef BirnetInt64 Birnet::int64
bsewavetool.cc:95: error: reference to 'int64' is ambiguous
../sfi/sfiwrapper.h:39: error: candidates are: typedef BirnetInt64 int64
../birnet/birnetutils.hh:35: error:                 typedef BirnetInt64 Birnet::int64
bsewavetool.cc:95: error: expected `;' before 'j'
Comment 1 Stefan Westerfeld 2007-07-12 22:29:02 UTC
Created attachment 91702 [details] [review]
patch that allows using int64 in bsewavetool.cc

My recommendation for fixing this is to use the original C++ types from the Birnet namespace in sfiwrapper.h, when compiling a C++ source. That way only one definition (the one from the Birnet namespace) will be available. I did a clean rebuild, and things work with the patch applied (make report).
Comment 2 Tim Janik 2007-07-13 08:13:08 UTC
Comment on attachment 91702 [details] [review]
patch that allows using int64 in bsewavetool.cc

>Index: sfi/sfiwrapper.cc
>===================================================================
>--- sfi/sfiwrapper.cc	(revision 4356)
>+++ sfi/sfiwrapper.cc	(working copy)
>@@ -15,7 +15,6 @@
>  * with this library; if not, see http://www.gnu.org/copyleft/.
>  */
> #include "sfiwrapper.h"
>-#undef BIRNET__RUNTIME_PROBLEM
> #include <birnet/birnet.hh>
> #include <errno.h>
> 

please provide a proper motivation for this change and describe why you think it is neccessary.

>Index: sfi/ChangeLog
>===================================================================
>--- sfi/ChangeLog	(revision 4356)
>+++ sfi/ChangeLog	(working copy)
>@@ -1,3 +1,14 @@
>+Thu Jul 12 23:56:34 2007  Stefan Westerfeld  <stefan@space.twc.de>
>+
>+	* sfiwrapper.h: When compiled in C++ sources, use [u]int16/32/...
>+	typedefs from Birnet instead of providing own typedefs. This allows
>+	using these types in C++ sources which are using namespace Birnet.
>+	Fixes #456408.
>+
>+	* sfiwrapper.cc: There doesn't seem to be any need to #undef
>+	BIRNET__RUNTIME_PROBLEM, but it causes problems with the changed
>+	header, so I removed it.
>+

"it causes problems"? unaccaptable, this provides close to *0* information for me, please say *why* you changed something, *not* *what* you changed (i cvan tell the *what* from the code).
i.e. described/analyse/etc the "problem" you think you're seeing.

> Mon Apr 16 13:51:51 2007  Stefan Westerfeld  <stefan@space.twc.de>
> 
> 	* sfidl-*[hc]: Refactored some code in order to remove unneccessary
>Index: sfi/sfiwrapper.h
>===================================================================
>--- sfi/sfiwrapper.h	(revision 4356)
>+++ sfi/sfiwrapper.h	(working copy)
>@@ -26,9 +26,19 @@
>  * provided by libbirnet.
>  */
> 
>-BIRNET_EXTERN_C_BEGIN();
>-
> /* --- short integer types --- */
>+#ifdef __cplusplus
>+#include <birnet/birnetutils.hh>
>+using Birnet::uint8;
>+using Birnet::uint16;
>+using Birnet::uint32;
>+using Birnet::uint64;
>+using Birnet::int8;
>+using Birnet::int16;
>+using Birnet::int32;
>+using Birnet::int64;
>+using Birnet::unichar;
>+#else
> typedef BirnetUInt8   uint8;
> typedef BirnetUInt16  uint16;
> typedef BirnetUInt32  uint32;
>@@ -38,6 +48,9 @@ typedef BirnetInt16   int16;
> typedef BirnetInt32   int32;
> typedef BirnetInt64   int64;
> typedef BirnetUnichar unichar;
>+#endif
>+
>+BIRNET_EXTERN_C_BEGIN();
> 
> /* --- initialization --- */
> typedef struct

this looks good, however due to the magic BIRNET__RUNTIME_PROBLEM change this patch can't be approved, pülease elaborate further.
Comment 3 Stefan Westerfeld 2007-07-13 08:35:35 UTC
(In reply to comment #2)
> (From update of attachment 91702 [details] [review] [edit])
> >Index: sfi/sfiwrapper.cc
> >===================================================================
> >--- sfi/sfiwrapper.cc  (revision 4356)
> >+++ sfi/sfiwrapper.cc  (working copy)
> >@@ -15,7 +15,6 @@
> >  * with this library; if not, see http://www.gnu.org/copyleft/.
> >  */
> > #include "sfiwrapper.h"
> >-#undef BIRNET__RUNTIME_PROBLEM
> > #include <birnet/birnet.hh>
> > #include <errno.h>
> > 
> 
> please provide a proper motivation for this change and describe why you think
> it is neccessary.

The reason this causes problems is that BIRNET__RUNTIME_PROBLEM gets defined by birnet/birnetutils.hh. So after the changes in sfi/sfiwrapper.h, the proper and correct definition of BIRNET__RUNTIME_PROBLEM will be available in sfi/sfiwrapper.cc. However, the code undefines it, and then includes the rest of birnet/birnet.hh. Parts of that code (the signal code) depend on the presence of the macro, which however does not get redefined, because of the include guards in birnet/birnetutils.hh (which was included before, as sfi/sfiwrapper.cc is a C++ file).

So more generally speaking, leaving it in place causes a compilation error of sfiwrapper.cc, since BIRNET__RUNTIME_PROBLEM is required but not defined by some birnet headers.
Comment 4 Tim Janik 2007-07-13 16:48:02 UTC
(In reply to comment #3)
> (In reply to comment #2)

> > >-#undef BIRNET__RUNTIME_PROBLEM

> > please provide a proper motivation for this change and describe why you think
> > it is neccessary.
> 
> The reason this causes problems is that BIRNET__RUNTIME_PROBLEM gets defined by
> birnet/birnetutils.hh. So after the changes in sfi/sfiwrapper.h, the proper and
> correct definition of BIRNET__RUNTIME_PROBLEM will be available in
> sfi/sfiwrapper.cc. However, the code undefines it, and then includes the rest
> of birnet/birnet.hh. Parts of that code (the signal code) depend on the
> presence of the macro, which however does not get redefined, because of the
> include guards in birnet/birnetutils.hh (which was included before, as
> sfi/sfiwrapper.cc is a C++ file).

thanks, if you provide the WHY with the changelog this time, this can go in now.

> So more generally speaking, leaving it in place causes a compilation error of
> sfiwrapper.cc, since BIRNET__RUNTIME_PROBLEM is required but not defined by
> some birnet headers.

that's ok, anyone including birnet, should *only* include birnet.hh, and that draws in the neccessary headers in the correct order.
Comment 5 Stefan Westerfeld 2007-07-14 14:04:58 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> 
> > > >-#undef BIRNET__RUNTIME_PROBLEM
> 
> > > please provide a proper motivation for this change and describe why you think
> > > it is neccessary.
> [...]
> thanks, if you provide the WHY with the changelog this time, this can go in
> now.

Committed with new ChangeLog entry. Feel free to edit the entry in SVN if you think its not precise enough. It looks like this now:

Sat Jul 14 15:54:33 2007  Stefan Westerfeld  <stefan@space.twc.de>

        * sfiwrapper.h: When compiled in C++ sources, use [u]int16/32/...
        typedefs from Birnet instead of providing own typedefs. This allows
        using these types in C++ sources which are using namespace Birnet.
        Fixes #456408.

        * sfiwrapper.cc: Since this is a C++ source, after the change above,
        birnet/birnetutils.hh will already get included in sfi/sfiwrapper.h.
        But then, undefining BIRNET__RUNTIME_PROBLEM afterwards will create
        compile errors in the other birnet headers which are included after
        sfi/sfiwrapper.h, because they rely on a definition provided by
        birnet/birnetutils.hh. So I am removing the #undef, which doesn't seem
        to have any useful purpose anyway.