From 98f9e14323bf806f674b3cc259e19ef6219b4378 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 21 Dec 2015 11:37:21 +0100 Subject: [PATCH] common: New file fwddecl.h. * common/util.h (server_control_s, ctrl_t): Move to ... * common/fwddecl.h: New file. * common/call-gpg.h: Replace typedef by fwddecl.h. Change include protection macro name. * common/Makefile.am (common_sources): Add fwddecl.h. -- It seems some compilers do not grok a re-declaration. Thus we factor it out into a separate file and use the include protection macro to protect against re-declaration. GnuPG-bug-id: 2200 Signed-off-by: Werner Koch --- common/Makefile.am | 2 +- common/call-gpg.h | 9 ++++----- common/fwddecl.h | 39 +++++++++++++++++++++++++++++++++++++++ common/util.h | 8 +------- 4 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 common/fwddecl.h diff --git a/common/Makefile.am b/common/Makefile.am index 54dee54ae..d09f0df76 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -42,7 +42,7 @@ include $(top_srcdir)/am/cmacros.am common_sources = \ common-defs.h \ - util.h i18n.c i18n.h \ + util.h fwddecl.h i18n.c i18n.h \ types.h host2net.h dynload.h w32help.h \ mapstrings.c stringhelp.c stringhelp.h \ strlist.c strlist.h \ diff --git a/common/call-gpg.h b/common/call-gpg.h index 74d381985..19993ef0b 100644 --- a/common/call-gpg.h +++ b/common/call-gpg.h @@ -17,15 +17,14 @@ * along with this program; if not, see . */ -#ifndef G13_CALL_GPG_H -#define G13_CALL_GPG_H +#ifndef GNUPG_COMMON_CALL_GPG_H +#define GNUPG_COMMON_CALL_GPG_H #include +#include "fwddecl.h" #include "strlist.h" -typedef struct server_control_s *ctrl_t; - gpg_error_t gpg_encrypt_blob (ctrl_t ctrl, const char *gpg_program, strlist_t gpg_arguments, @@ -52,4 +51,4 @@ gpg_error_t gpg_decrypt_stream (ctrl_t ctrl, estream_t cipher_stream, estream_t plain_stream); -#endif /*G13_CALL_GPG_H*/ +#endif /*GNUPG_COMMON_CALL_GPG_H*/ diff --git a/common/fwddecl.h b/common/fwddecl.h new file mode 100644 index 000000000..92f045389 --- /dev/null +++ b/common/fwddecl.h @@ -0,0 +1,39 @@ +/* fwddecl.h - Formward declarations + * Copyright (C) 2015 Werner Koch + * + * This file is part of GnuPG. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either + * + * - the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * or + * + * - the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * or both in parallel, as here. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef GNUPG_COMMON_FWDDECL_H +#define GNUPG_COMMON_FWDDECL_H + + +/*-- Forward declaration of the commonly used server control structure. */ +struct server_control_s; +typedef struct server_control_s *ctrl_t; + + +#endif /*GNUPG_COMMON_FWDDECL_H*/ diff --git a/common/util.h b/common/util.h index e05cbff32..5d94e93c0 100644 --- a/common/util.h +++ b/common/util.h @@ -52,6 +52,7 @@ #include "../common/dotlock.h" #include "../common/utf8conv.h" #include "../common/dynload.h" +#include "../common/fwddecl.h" #include "gettime.h" @@ -346,11 +347,4 @@ int _gnupg_isatty (int fd); #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) #define xtoi_4(p) ((xtoi_2(p) * 256) + xtoi_2((p)+2)) - -/*-- Forward declaration of the commonly used server control structure. */ -/* (We need it here as it is used by some callback prototypes.) */ -struct server_control_s; -typedef struct server_control_s *ctrl_t; - - #endif /*GNUPG_COMMON_UTIL_H*/