Sfoglia il codice sorgente

Unify usage of extern "C" declarations

Guillem Jover 18 anni fa
parent
commit
1065736ab0

+ 30 - 0
ChangeLog

@@ -1,3 +1,33 @@
+2008-08-24  Guillem Jover  <guillem@debian.org>
+
+	* lib/dpkg-def.h (DPKG_BEGIN_DECLS, DPKG_END_DECLS): New macros.
+	* lib/dpkg.h: Surround declarations with DPKG_BEGIN_DECLS and
+	DPKG_END_DECLS.
+	* lib/myopt.h: Likewise.
+	* lib/dpkg-db.h: Likewise. Include <dpkg-def.h>.
+	* lib/dpkg-priv.h: Include <dpkg-def.h>. Replace extern "C" context
+	with DPKG_BEGIN_DECLS and DPKG_END_DECLS.
+	* dselect/basecmds.cc: Remove surrounding extern "C" context from
+	header files.
+	* dselect/baselist.cc: Likewise.
+	* dselect/basetop.cc: Likewise.
+	* dselect/bindings.cc: Likewise.
+	* dselect/curkeys.cc: Likewise.
+	* dselect/helpmsgs.h: Likewise.
+	* dselect/main.cc: Likewise.
+	* dselect/methkeys.cc: Likewise.
+	* dselect/methlist.cc: Likewise.
+	* dselect/method.cc: Likewise.
+	* dselect/methparse.cc: Likewise.
+	* dselect/pkgcmds.cc: Likewise.
+	* dselect/pkgdepcon.cc: Likewise.
+	* dselect/pkgdisplay.cc: Likewise.
+	* dselect/pkginfo.cc: Likewise.
+	* dselect/pkgkeys.cc: Likewise.
+	* dselect/pkglist.cc: Likewise.
+	* dselect/pkgsublist.cc: Likewise.
+	* dselect/pkgtop.cc: Likewise.
+
 2008-08-24  Guillem Jover  <guillem@debian.org>
 
 	* lib/dpkg-def.h: Do not include <config.h>.

+ 4 - 4
dselect/basecmds.cc

@@ -19,17 +19,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
+
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
+
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "helpmsgs.h"
 

+ 2 - 4
dselect/baselist.cc

@@ -19,9 +19,8 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
@@ -31,10 +30,9 @@ extern "C" {
 #include <sys/ioctl.h>
 #include <sys/termios.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 3 - 4
dselect/basetop.cc

@@ -18,18 +18,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
+
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 
 void baselist::refreshlist() {

+ 2 - 4
dselect/bindings.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 2 - 2
dselect/curkeys.cc

@@ -19,11 +19,11 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-extern "C" {
 #include <config.h>
+
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 0 - 2
dselect/helpmsgs.h

@@ -22,9 +22,7 @@
 #ifndef HELPMSGS_H
 #define HELPMSGS_H
 
-extern "C" {
 #include <dpkg.h>
-}
 
 struct helpmessage {
   const char *title;

+ 2 - 4
dselect/main.cc

@@ -19,9 +19,8 @@
  * License along with dpkg; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
@@ -39,11 +38,10 @@ extern "C" {
 
 #include <ncursesw/term.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <myopt.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 #include "pkglist.h"

+ 2 - 4
dselect/methkeys.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 2 - 4
dselect/methlist.cc

@@ -19,19 +19,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 #include "method.h"

+ 2 - 4
dselect/method.cc

@@ -19,9 +19,8 @@
  * License along with dpkg; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
@@ -40,10 +39,9 @@ extern "C" {
 #include <fcntl.h>
 #include <sys/file.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include <dpkg-priv.h>
 #include "dselect.h"
 #include "method.h"

+ 2 - 5
dselect/methparse.cc

@@ -18,9 +18,8 @@
  * License along with dpkg; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
@@ -35,11 +34,9 @@ extern "C" {
 #include <ctype.h>
 #include <assert.h>
 
-
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 #include "method.h"

+ 2 - 4
dselect/pkgcmds.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "pkglist.h"
 

+ 2 - 4
dselect/pkgdepcon.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "pkglist.h"
 

+ 2 - 4
dselect/pkgdisplay.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "pkglist.h"
 

+ 2 - 4
dselect/pkginfo.cc

@@ -18,19 +18,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 #include "helpmsgs.h"

+ 2 - 4
dselect/pkgkeys.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 2 - 4
dselect/pkglist.cc

@@ -19,19 +19,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 2 - 4
dselect/pkgsublist.cc

@@ -18,18 +18,16 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "bindings.h"
 

+ 2 - 4
dselect/pkgtop.cc

@@ -18,19 +18,17 @@
  * License along with this; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-extern "C" {
+
 #include <config.h>
-}
 
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
 
-extern "C" {
 #include <dpkg.h>
 #include <dpkg-db.h>
-}
+
 #include "dselect.h"
 #include "pkglist.h"
 

+ 7 - 0
lib/dpkg-db.h

@@ -23,6 +23,10 @@
 #ifndef DPKG_DB_H
 #define DPKG_DB_H
 
+#include <dpkg-def.h>
+
+DPKG_BEGIN_DECLS
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -450,4 +454,7 @@ struct lstitem;
 struct lstitem* parseformat(const char* fmt);
 void freeformat(struct lstitem* head);
 void show1package(const struct lstitem* head, struct pkginfo *pkg);
+
+DPKG_END_DECLS
+
 #endif /* DPKG_DB_H */

+ 8 - 0
lib/dpkg-def.h

@@ -34,4 +34,12 @@
 # define UNUSED
 #endif
 
+#ifdef __cplusplus
+#define DPKG_BEGIN_DECLS	extern "C" {
+#define DPKG_END_DECLS		}
+#else
+#define DPKG_BEGIN_DECLS
+#define DPKG_END_DECLS
+#endif
+
 #endif

+ 4 - 6
lib/dpkg-priv.h

@@ -22,9 +22,9 @@
 #ifndef DPKG_PRIV_H
 #define DPKG_PRIV_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <dpkg-def.h>
+
+DPKG_BEGIN_DECLS
 
 #include <stddef.h>
 
@@ -56,9 +56,7 @@ const char *skip_slash_dotslash(const char *path);
 void setup_subproc_signals(const char *name);
 void cu_subproc_signals(int argc, void **argv);
 
-#ifdef __cplusplus
-}
-#endif
+DPKG_END_DECLS
 
 #endif /* DPKG_PRIV_H */
 

+ 6 - 2
lib/dpkg.h

@@ -23,6 +23,10 @@
 #ifndef DPKG_H
 #define DPKG_H
 
+#include <dpkg-def.h>
+
+DPKG_BEGIN_DECLS
+
 #include <setjmp.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -30,8 +34,6 @@
 
 #include <myopt.h>
 
-#include <dpkg-def.h>
-
 #ifdef HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
@@ -460,4 +462,6 @@ void unsetenv(const char *x);
 #define _(String) gettext (String)
 #define N_(String) gettext_noop (String)
 
+DPKG_END_DECLS
+
 #endif /* DPKG_H */

+ 4 - 0
lib/myopt.h

@@ -24,6 +24,8 @@
 
 #include <dpkg-def.h>
 
+DPKG_BEGIN_DECLS
+
 typedef void (*voidfnp)(void);
 
 struct cmdinfo {
@@ -51,4 +53,6 @@ void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
 void usage(void);
 void printversion(void);
 
+DPKG_END_DECLS
+
 #endif /* MYOPT_H */