discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Converting from #ifndef/#define include guards to #pr


From: Marcus Müller
Subject: [Discuss-gnuradio] Converting from #ifndef/#define include guards to #pragma once globally
Date: Sat, 22 Feb 2014 23:01:20 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello community,

after finding a minor mistake in a header include file this week, I've
wanted to make sure that the GR header files have proper,
non-conflicting include guards.

So I want to open the discussion whether GR would want to change from
#ifndef-based include guards to #pragma once.

What I noticed is:
* there were 881 files that contained the classical
        #ifdef MACRO_WHATEVER
        #define MACRO_WHATEVER
        ...
        #endif /*maybe some comment*/
  scheme in current master
* replacing these with #pragma once has not damaged anything (as far
as one simple make test can tell)
* one minor mis-#define was found only which I believe is very
reassuring for our overall code quality (1) (2).

I've created a script (3) that checks (4) whether c++ files follow the
classical include guard methodology, and replaces that with a #pragma
once. cmake && make && make test worked fine on the first run :) which
made me confident enough to push everything (changed headers and the
script) to a branch:

https://github.com/marcusmueller/gnuradio/tree/convert_to_pragma_once

It would be great if people running other toolchains than I do
(gcc4.8.2/x86_64) would check if it breaks stuff.

If there is enough interest and consensus that we might want to switch
over to #pragma once (instead of just doing this "for testing purposes
only"), I think it'd be worthwhile to tackle things that stayed
untouched during automatic conversion:
* .t templates
* the newmod architecture

Greetings,
Marcus

(1) see my pull request against master
(2) however, vocoder/gsm/config.h uses #ifndef CONFIG_H, which I think
is a little bit asking for trouble
(3)
https://github.com/marcusmueller/gnuradio/blob/convert_to_pragma_once/dtools/bin/convert_ifndef_to_pragma_once
(4) checking is done by running it through the C preprocessor once to
get rid of comments and check the first line against an #ifndef macro,
and a second time to check whether defining that macro causes the file
to semantically disappear.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTCR4wAAoJEAFxB7BbsDrLj3oH/0NJi0qUT1Pj5FKMISU31tay
glCG1TG1j9Bj0r/NgaOook0pOgZrv2q5ZCDAJWgEnbxm8iI8NCiyYEorOhmoK5k7
GzACT4OTfQdISEq90zuvRelVxyFcRavxemI3d4hPTad3DHMIxLDzMtdYYROdCG2+
SUNuKzw9CiYPeXPuUNgChUAYxHDZSqCD+MpUBgOCeOtn9wa5eM7bJv8nuITsf0+h
13wW/EdEfQGkVuRyUIQySD2O8zvqNXobmzYRpmYnUkYg2tPxG5Kv6YAqhrFZY9El
hhJrmfI7Z6UK+zbq8Kt6qWHeXMglOGQVwFU1cZ0jZAvpZRiwJTzSeNBpF6LKcbE=
=WNPJ
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]