extra semicolons in header file are not portable

Johnathan Burchill <[email protected]> Thu, 09 Sep 2004 10:42:05 -0600
Newsgroups gmane.comp.sysutils.backup.dar.libdar
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Denis,

I've gotten a couple of reports from users trying to compile KDar using gcc 
3.4.1. The configure script fails on checking the usability of libdar.hpp 
and on checking for libdar.so:

e.g.

configure:28461: checking for libdar
configure:28489: g++ -o conftest -Wnon-virtual-dtor -Wno-long-long -Wundef 
- -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings 
- -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2 
- -fno-exceptions -fno-check-new -fexceptions -fexceptions  
- -DQT_THREAD_SUPPORT  -D_REENTRANT -ldar conftest.cc  >&5
cc1plus: warning: command line option "-Wmissing-prototypes" is valid for 
Ada/C/ObjC but not for C++
In file included from /usr/local/include/dar/infinint.hpp:30,
                 from /usr/local/include/dar/generic_file.hpp:38,
                 from /usr/local/include/dar/compressor.hpp:30,
                 from /usr/local/include/dar/libdar.hpp:30,
                 from conftest.cc:50:
/usr/local/include/dar/real_infinint.hpp:110: error: extra semicolon
configure:28492: $? = 1
configure: program exited with status 1

The code near line 110 of real_infinint.hpp (in dar-2.1.4) is 
        template <class T>void unstack(T &v) throw(Ememory, Erange, Ebug)
            { E_BEGIN; infinint_unstack_to(v); E_END("infinint::unstack", 
typeid(v).name()); };

Apparently gcc-3.4.1 doesn't accept the last ";" when -pedantic is passed.

I checked into this and found the following site with some tips on making 
code portable:

http://www.mozilla.org/hacking/portable-cpp.html

Tip #12 is relevant here:
http://www.mozilla.org/hacking/portable-cpp.html#no_extra_semi_colons

It specifically mentions gcc-3.4.

Comments? The obvious solution is to remove the extra semicolons from the 
header files.

The only temporary fix I can think of is to make a patch available for dar 
to allow other programs to link to the library with gcc-3.4. Unless the 
users disable the "-pedantic" switch, but I don't have gcc-3.4 so I can't 
test this at the moment.

Cheers,
JB
- -- 
Johnathan K. Burchill, Ph.D.
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBQIfdrXMSOtiWrO4RAjdfAJ9URMP2kVlRye6bpGdb9E7rotiHGQCgim+c
rzJtxA52lZGbHnnzc727VN4=
=ywk6
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php