[bug-gettext] gettext-0.19.8.1 requires a few patches to compile with st
From:
Dennis Clarke
Subject:
[bug-gettext] gettext-0.19.8.1 requires a few patches to compile with strict C99 compiler
Date:
Sun, 18 Jun 2017 15:54:21 -0400
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1
A few patches were needed to compile gettext-0.19.8.1 on Solaris 10
using both Oracle Studio 12.4 and Oracle Studio 12.5 compilers. The
problems seemed to be exclusively to some issue around the use of _Bool
and then "bool" in other place and a mismatch between header files and
the C source files that reference them.
These adjustments solve all these issues :
*** ./gettext-tools/src/xgettext.h_backup Sun Mar 20 07:37:53 2016
--- ./gettext-tools/src/xgettext.h Sun Jun 18 16:47:46 2017
***************
*** 363,369 ****
enum
literalstring_escape_type type);
/* Tests whether an arglist_parser has is not waiting for more
arguments after
argument ARGNUM. */
! extern bool arglist_parser_decidedp (struct arglist_parser *ap, int
argnum);
/* Terminates the processing of an arglist_parser after argument
ARGNUM and
deletes it. */
extern void arglist_parser_done (struct arglist_parser *ap, int argnum);
--- 363,369 ----
enum
literalstring_escape_type type);
/* Tests whether an arglist_parser has is not waiting for more
arguments after
argument ARGNUM. */
! extern signed char arglist_parser_decidedp (struct arglist_parser *ap,
int argnum);
/* Terminates the processing of an arglist_parser after argument
ARGNUM and
deletes it. */
extern void arglist_parser_done (struct arglist_parser *ap, int argnum);
*** ./gettext-tools/src/read-catalog-abstract.h_backup Sun Mar 20
07:37:53 2016
--- ./gettext-tools/src/read-catalog-abstract.h Sun Jun 18 16:01:05 2017
***************
*** 182,188 ****
/* Parse a special comment and put the result in *fuzzyp, formatp,
*rangep,
! extern signed char markup_parse_context_parse (markup_parse_context_ty
*context,
const char *text,
ssize_t text_len);
! extern signed char markup_parse_context_end_parse
(markup_parse_context_ty *context);
extern const char *
markup_parse_context_get_error (markup_parse_context_ty *context);
The use of a thing called "bool" seemed the be the issue here and
ultimately a "_Bool" really is just the smallest rant data element that
can contain a zero or a one value and I think an unsigned char should be
able to do the job neatly. For reasons unknown I needed to use signed
char and that solved all the compile issues.
The most up to date rev of the standard headers in Solaris 10 would be :
PKGINST: SUNWhea
NAME: SunOS Header Files
CATEGORY: system
ARCH: sparc
VERSION: 11.10.0,REV=2005.01.21.15.53
BASEDIR: /
VENDOR: Oracle Corporation
DESC: SunOS C/C++ header files for general development of software
PSTAMP: on10-patch20170424132434
INSTDATE: May 19 2017 03:01
HOTLINE: Please contact your local service provider
STATUS: completely installed
FILES: 1626 installed pathnames
42 shared pathnames
128 directories
22856 blocks used (approx)
That PSTAMP seems to suggest we have updates April this year but
stdbool.h has not changed since 2005 and it only exists if we actually
use a strict C99 compliant compiler :
$ cat /usr/include/stdbool.h
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#pragma ident "@(#)stdbool.h 1.1 03/12/04 SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Included for alignment with the ISO/IEC 9899:1999 standard. The
* contents of this header are only visible when using a c99
* compiler, otherwise inclusion of this header will result in a
* forced compilation failure.
*
* Note that the ability to undefine and redefine the macros bool,
* true, and false is an obsolescent feature which may be withdrawn
* in a future version of the standards specifications.
*/
#include <sys/feature_tests.h>
#if defined(_STDC_C99)
#undef bool
#undef true
#undef false
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#else /* _STDC_C99 */
#error "Use of <stdbool.h> is valid only in a c99 compilation environment."
#endif /* _STDC_C99 */
#ifdef __cplusplus
}
#endif
#endif /* _STDBOOL_H */
So right there we see a define for "bool" as just _Bool and there even
exists a flag __bool_true_false_are_defined but since it has leading
underscores we should ignore that. Maybe :
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdbool.h.html
So I could go digging madly to figure out what *really* goes wrong but I
can tell you that C99 compiler issues a number of errors that all look
the same :
gmake: *** [all] Error 2
So there we see some confusion over the use of "_Bool" in some places
and "bool" in other and yet the "signed char" essentially solves the
issue if we read the C99 spec correctly. Personally I think a true or
false value can fit neatly in an unsigned char and that solves the whole
mess.
Dennis Clarke