Apache OpenOffice (AOO) Bugzilla – Issue 108631
Preprocessor defines in layout-pre.hxx to save typing namespace qualifiers break compile
Last modified: 2017-05-20 11:28:07 UTC
In layout-pre.hxx are preprocessor defines of the form #define symbol layout::symbol Those symbols are put as arguments into other macros (IMPL_LINK, zoom.cxx) resulting in double expansion with Sun's cc: symbol becomes layout::layout::symbol. I think this technique undergoes the C++-namespace concept and in addition it prevents compilation. One should make it either explicit by 'using namespace layout;' or should replace the macro instantiations within the code by their definitions (my personal preference).
@ hr: Please have a look.
Created attachment 67401 [details] Patch against svn trunk rev. 277953 + sh-/GNU m4-script to create it
I created the patch above to replace all those bad defines by their definition in all sources including a 'layout-pre.hxx' (determined through simple grepping). In files including 'sfx2/layout-pre.hxx' I replaced SfxDialog, SfxModalDialog, SfxModelessDialog by layout::SfxDialog each. Since I haven't set up an environment to compile a trunk, I've not tested it, but this technic works on OOO_310_m19 with some minor modifications. Please note that '::Window' has to be replaced by 'Windows' to make the source compilable by Sun's cc although I'm not sure why and thus this change is not cotnained within the patch. Since the definition of LocalizedString depends on the preprocessor macro ENABLE_LAYOUT, I left it as is, but it's still bad code (when a LocalizedString is put as an argument into another macro the problem initially described arises). Maybe one tests ENABLE_LAYOUT at all places a Localized string is used or renames the macro, maybe prepending it with an underscore, to prevent its multiple expansion.
sorry, of cource I mean '::Window' has to be replaces by 'Window'
sorry for frequent posting, but I just want to note, that the m4 processor has to be the GNU m4 as the '-P'-option is necessary!
@nstange: May I ask which version of Sun CC you are using? We do compile all our stuff Sun Studio 12 and I'm not aware of any breakage in this area. @mba,@jcn: opinions?
Sorry, here it is: cc -V cc: Sun C 5.9 SunOS_sparc 2007/05/03 It's part of SunStudio12.
@nstange: this is the compiler we use as well, albeit a slightly newer patch level: CC: Sun C++ 5.9 SunOS_sparc Patch 124863-08 2008/10/16 The patch might explain while we got no problem with the "::Window" vs. "Window" construct, I think I have a very weak recollection of something being temporarily broken in this respect with FCS Sun C++ 5.9 I won't comment on the macro expansion vs. namespace issue as the responsible engineers are more qualified to do so. @mba: reassign @mba, jcn: please comment
@nstange: thanks for looking into this, in fact this code creates a problem (not only) on Solaris. Jan, I would like to get your opinion about that.
I'm adding this comment to all open issues with Issue Type == PATCH. We have 220 such issues, many of them quite old. I apologize for that. We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0. If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know. On the other hand, if the patch is no longer relevant, please let us know that as well. If you have any general questions or want to discuss this further, please send a note to our dev mailing list: dev@openoffice.apache.org Thanks! -Rob
Reset assigne to the default "issues@openoffice.apache.org".