[opensuse-packaging] GCC 4.3 transition and fallout in your packages
The upcoming transition to GCC 4.3 will cause some common problems in C and C++ source to become compile-time errors. You investigate if your Factory package is affected by looking at the home:dirkmueller:playground:gcc43 project which is currently rebuilding (most of) Factory with GCC 4.3. Common problems include: 1) Missing includes. The include dependencies of the standard library headers were cleaned up a lot and a lot less unneeded dependencies are pulled in. This results in errors like Geometry.cpp: In member function 'const Magick::Geometry& Magick::Geometry::operator=(const std::string&)': Geometry.cpp:191: error: 'strcpy' was not declared in this scope make[3]: *** [Geometry.lo] Error 1 which hints at that you should include <cstring>, the C++ standard include name of the C string.h header. The rule of thumb is to look in which C header the missing function is in and then include the C++ variant which has a 'c' prepended and the '.h' stripped off. This is 90% of all errors we currently see with C++ programs. 2) There are extra warnings with GCC 4.3 and you use -Werror. You simply need to fix them. 3) More picky preprocessor: main.cpp:182:7: error: extra tokens at end of #endif directive the preprocessor diagnoses #endif foo use #endif /* foo */ instead. 4) C99 inline semantics changes. If you use 'extern inline foo(....' in headers and build with either -std=c99 or -std=gnu99 then you will probably face linker errors complaining about duplicate symbols. If you want to fix this in a way that is compatible with GCC 4.3 and previous versions use something like the following: extern inline #ifdef __GNU_STDC_INLINE__ __attribute__((__gnu_inline__)) #endif foo(.... which will preserve the previous semantics. If you do not care about compatibility with older GCC and want to use C99 semantics simply remove the 'extern' qualifier on inline functions defined in headers. 5) If you see something like /usr/include/zypp/Bit.h:86: error: declaration of 'typedef struct zypp::bit::MaxBits<_IntT> zypp::bit::Range<_IntT, _begin, _size>::MaxBits' /usr/include/zypp/Bit.h:52: error: changes meaning of 'MaxBits' from 'struct zypp::bit::MaxBits<_IntT>' you did something like template <class T> struct Foo : public FooBar<T> { typedef Foo::FooBar<T> FooBar; ... this is invalid C++. Use a different typedef-name here: typedef Foo::FooBar<T> FooBar_t; --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Mon, 24 Sep 2007, Richard Guenther wrote:
The upcoming transition to GCC 4.3 will cause some common problems in C and C++ source to become compile-time errors. You investigate if your Factory package is affected by looking at the home:dirkmueller:playground:gcc43 project which is currently rebuilding (most of) Factory with GCC 4.3.
Common problems include:
And I just C&P this to the wiki: http://en.opensuse.org/GCC_4.3_Transition Richard. --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On Monday, 24. September 2007, Richard Guenther wrote:
The upcoming transition to GCC 4.3 will cause some common problems in C and C++ source to become compile-time errors. You investigate if your Factory package is affected by looking at the home:dirkmueller:playground:gcc43 project which is currently rebuilding (most of) Factory with GCC 4.3.
.. and do not forget to mail the patch upstream! It seems that Ubuntu currently does a gcc 4.3 transition, so in some cases the bug might be already fixed upstream and all that you need to do is a new source drop. Greetings, Dirk -- RPMLINT information under http://en.opensuse.org/Packaging/RpmLint --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Richard Guenther wrote:
Geometry.cpp: In member function 'const Magick::Geometry& Magick::Geometry::operator=(const std::string&)': Geometry.cpp:191: error: 'strcpy' was not declared in this scope make[3]: *** [Geometry.lo] Error 1 which hints at that you should include <cstring>, the C++ standard include name of the C string.h header. The rule of thumb is to look in which C header the missing function is in and then include the C++ variant which has a 'c' prepended and the '.h' stripped off.
As a rule of thumb I would mainly advise to use #include <string.h>, if the file that contains the strcpy does not have the std:: namespace flattened. <cstring> puts the <string.h> functions into the std:: namespace and adding namespace flattening where upstream did not intend to put it might be broken, since some those flattenings work well with gcc, but are completely broken with MSVC++ or Sun Studio :-) BTW, for libwpg, libwpd, wpd2sxw and wpg2sxw, libraries that I maintain, the gcc 4.3 changes are incorporated in corresponding CVS. I will release them little by little when we reach a critical amount of bug-fixes (I have released all of them less then a month ago :-() Cheers Fridrich -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFG+Awku9a1imXPdA8RAq3vAJ40B/Q2E1hq/+ymq6VqISqd+svPewCfaIbM uoBmJx6PCkqRVwmkE3Dgenw= =u8Bl -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
participants (3)
-
Dirk Mueller
-
Fridrich Strba
-
Richard Guenther