Bug 46384

Summary: tp-glib fails to build on Android and windows
Product: Telepathy Reporter: Alvaro Soliverez <alvaro.soliverez>
Component: tp-glibAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: major    
Priority: medium CC: rohan
Version: git masterKeywords: patch
Hardware: Other   
OS: All   
URL: http://cgit.freedesktop.org/~smcv/telepathy-glib/commit?h=forward-decl
Whiteboard:
i915 platform: i915 features:
Attachments: Avoid forward-declaring Call classes
Avoid forward-declaring Call classes
Remove another unnecessary forward-declaration of TpBaseCallChannel

Description Alvaro Soliverez 2012-02-21 03:28:56 UTC
../telepathy-glib/base-call-content.h:35:35: error: redefinition of typedef 'TpBaseCallChannel'
../telepathy-glib/base-call-stream.h:33:35: note: previous declaration of 'TpBaseCallChannel' was here
In file included from base-call-channel.c:103:0:
base-call-channel.h:30:35: error: redefinition of typedef 'TpBaseCallChannel'
../telepathy-glib/base-call-content.h:35:35: note: previous declaration of 'TpBaseCallChannel' was here
In file included from base-call-channel.c:108:0:
../telepathy-glib/base-call-internal.h:30:35: error: redefinition of typedef 'TpBaseCallChannel'
base-call-channel.h:30:35: note: previous declaration of 'TpBaseCallChannel' was here
../telepathy-glib/base-call-internal.h:31:35: error: redefinition of typedef 'TpBaseCallContent'
Latest tp-glib fails to build with similar errors in both platforms

../telepathy-glib/base-call-content.h:37:35: note: previous declaration of 'TpBaseCallContent' was here
../telepathy-glib/base-call-internal.h:32:35: error: redefinition of typedef 'TpBaseCallStream'
../telepathy-glib/base-call-stream.h:35:34: note: previous declaration of 'TpBaseCallStream' was here
In file included from ../telepathy-glib/base-media-call-stream.h:25:0,
                 from base-call-channel.c:109:
../telepathy-glib/call-stream-endpoint.h:33:38: error: redefinition of typedef 'TpCallStreamEndpoint'
../telepathy-glib/base-call-internal.h:37:38: note: previous declaration of 'TpCallStreamEndpoint' was here
In file included from base-call-channel.c:109:0:
../telepathy-glib/base-media-call-stream.h:29:39: error: redefinition of typedef 'TpBaseMediaCallStream'
../telepathy-glib/base-call-internal.h:36:39: note: previous declaration of 'TpBaseMediaCallStream' was here
make[2]: *** [base-call-channel.lo] Error 1
make[2]: Leaving directory `/var/lib/buildbot/telepathy/telepathy-glib-win/build/telepathy-glib'
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1
make[1]: Leaving directory `/var/lib/buildbot/telepathy/telepathy-glib-win/build/telepathy-glib'
program finished with exit code 2
elapsedTime=47.038328

See here for more details:
Windows build: http://buildbot.telepathy.im:8010/builders/telepathy-glib%20-%20windows/builds/16
Android build: http://buildbot.telepathy.im:8010/builders/telepathy-android%20-%20r10/builds/59
Comment 1 Simon McVittie 2012-02-21 06:00:20 UTC
What compiler version are you using? I'd like to be warned about this when not cross-compiling, too.

I believe my forward-decl branch fixes this.
Comment 2 Simon McVittie 2012-02-21 06:00:57 UTC
Created attachment 57393 [details] [review]
Avoid forward-declaring Call classes

Having more than one typedef for the same name is an error.

If forward declarations are needed to break cycles, the typedef must
be *moved* (not copied) from the header it'd normally appear in to the
header with the forward declaration: for instance, TpCallContent
(forward-declared in call-channel.h) gets this right. In extreme cases,
a global "types.h" header can forward-declare everything, although that
often leads to unnecessary compilation, so we've avoided it in
telepathy-glib.
Comment 3 Alvaro Soliverez 2012-02-21 06:10:45 UTC
(In reply to comment #1)
> What compiler version are you using? I'd like to be warned about this when not
> cross-compiling, too.

For Windows, we use mingw32. For Android, NDK R6.

I dunno how we can prevent this, other than using latest gcc with all warnings enabled, and paying attention to buildbot fails. In this, at least 6 other projects broke up and that is reported in IRC.
Comment 4 Simon McVittie 2012-02-21 06:39:44 UTC
(In reply to comment #3)
> For Windows, we use mingw32. For Android, NDK R6.

Those are platforms. Which compiler version do they contain? I assume it's some sort of gcc in both cases?

I didn't get these warnings with Debian's gcc 4.6.2-15, and I can't find an option to enable them, which is unfortunate, since it's an error to have multiple declarations like this.
Comment 5 Simon McVittie 2012-02-21 06:54:37 UTC
*** Bug 46396 has been marked as a duplicate of this bug. ***
Comment 6 Guillaume Desmottes 2012-02-21 06:59:31 UTC
Comment on attachment 57393 [details] [review]
Avoid forward-declaring Call classes

Review of attachment 57393 [details] [review]:
-----------------------------------------------------------------

++
Comment 7 Rohan Garg 2012-02-21 07:07:54 UTC
Created attachment 57399 [details] [review]
Avoid forward-declaring Call classes

Missed one, added a updated patch based on the previous patch
Comment 8 Alvaro Soliverez 2012-02-21 07:21:16 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > For Windows, we use mingw32. For Android, NDK R6.
> 
> Those are platforms. Which compiler version do they contain? I assume it's some
> sort of gcc in both cases?
> 

To build for Windows, we use mingw32-gcc 4.5.3, running on Fedora 15

To build for Android, we use the Android NDK Release 6, which uses its own compiler and libc library (bionic).
Comment 9 Simon McVittie 2012-02-21 07:43:28 UTC
Comment on attachment 57399 [details] [review]
Avoid forward-declaring Call classes

Review of attachment 57399 [details] [review]:
-----------------------------------------------------------------

::: telepathy-glib/base-call-channel.h
@@ +24,4 @@
>  
>  #include <telepathy-glib/base-channel.h>
>  #include <telepathy-glib/base-call-content.h>
> +#include <telepathy-glib/base-call-stream.h>

The forward declaration in this header seems to be unnecessary, so I'd prefer to just drop it. Additional patch on the way.
Comment 10 Simon McVittie 2012-02-21 07:46:23 UTC
Created attachment 57400 [details] [review]
Remove another unnecessary forward-declaration of  TpBaseCallChannel
Comment 11 Rohan Garg 2012-02-21 07:54:34 UTC
Everything compiles as expected with clang after applying these 2 patches :)
Comment 12 Simon McVittie 2012-02-21 08:03:28 UTC
(In reply to comment #2)
> Having more than one typedef for the same name is an error.

... but not in drafts of C1X, apparently, which is why gcc 4.6 no longer treats it as an error.

Still, we generally try to stick to C89 (!) because MSVC still hasn't caught up with C99, so we should certainly avoid relying on C1X.
Comment 13 Simon McVittie 2012-02-21 08:07:18 UTC
Fixed in git for 0.17.6

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.