Skip to content

typedef of bool in <rpcsvc/yp_prot.h> conflicts with the one in <sys/stdbool.h> #526

Description

@grubba

From <stdbool.h>:

#ifndef __cplusplus
#if defined(_STDC_C99) || defined(__C99FEATURES__) || __GNUC__ >= 3

#undef	bool
#undef	true
#undef	false

#define	bool	_Bool
#define	true	1
#define	false	0

#define	__bool_true_false_are_defined	1

#endif /* defined(_STDC_C99) || defined(__C99FEATURES__) || __GNUC__ >= 3 */
#endif /* __cplusplus */

<rpcsvc/yp_prot.h> in turn contains:

/* 'bool' is a built-in type for g++ */
#if !(defined(__cplusplus) && defined(_BOOL)) && !defined(__GNUG__)
#ifndef BOOL_DEFINED
typedef unsigned int bool;
#define	BOOL_DEFINED
#endif
#endif

The latter is a syntax error if the first #define is active as it expands to:

typedef unsigned int _Bool;

Where _Bool is a keyword in C11 and later.

BTW: Note also that bool in itself is a keyword in C23 and later.

My suggestion is to update <sys/stdbool.h> to:

  • Define BOOL_DEFINED (or alter the test in <rpcsvc/yp_prot.h> to check __bool_true_false_defined).
  • Update it to know about C23 (not strictly necessary as _Bool is still an alias).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions