Skip to content

Conversation

@veblush
Copy link
Contributor

@veblush veblush commented Sep 10, 2019

UPB is not strictly C89 compatible because it uses stdbool.h introduced with C99. The latest version of clang with -Wc99-extensions option throws an error saying it's not allowed with C89. So this PR removes the option.

# cat a.c
#include <stdbool.h>

int main() {
  bool a;
  return 0;
}

# clang a.c -std=c89

# clang a.c -std=c89 -Wc99-extensions
a.c:4:3: warning: '_Bool' is a C99 extension [-Wc99-extensions]
  bool a;
  ^
/usr/lib/llvm-10/lib/clang/10.0.0/include/stdbool.h:15:14: 
  note: expanded from macro 'bool'
#define bool _Bool
             ^
1 warning generated.

# clang a.c -std=c99 -Wc99-extensions

Fixes #212

@haberman
Copy link
Member

I want to stay c89 compatible if possible. I may introduce a UPB_BOOL macro that conditionally is defined to bool if C99 is available. But I'll approve this for now to unblock you.

@veblush veblush merged commit 9effcbc into protocolbuffers:master Sep 10, 2019
@veblush veblush deleted the c99 branch September 10, 2019 22:21
@yang-g
Copy link

yang-g commented Sep 10, 2019

Thanks for the quick fix!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUILD file specifies c89 in COPTS

4 participants