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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-12-21 11:37:21 +01:00
parent af142854a7
commit 98f9e14323
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 45 additions and 13 deletions

View File

@ -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 \

View File

@ -17,15 +17,14 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef G13_CALL_GPG_H
#define G13_CALL_GPG_H
#ifndef GNUPG_COMMON_CALL_GPG_H
#define GNUPG_COMMON_CALL_GPG_H
#include <gpg-error.h>
#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*/

39
common/fwddecl.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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*/

View File

@ -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*/