Skip to content

Commit

Permalink
Fix build with gcc (#27)
Browse files Browse the repository at this point in the history
Summary:
kDescriptor needs full qualification because gcc complained of a
mismatched declaration and definition otherwise.

SimpleFixedString conditions were reordered because
`#if defined(foo) && foo(bar)` is a preprocessor syntax error with gcc.
Pull Request resolved: facebookincubator/fbjni#27

Reviewed By: swolchok

Differential Revision: D19233972

Pulled By: dreiss

fbshipit-source-id: 60a2f1a9aa96ff4c35915e045481835041245c1f
  • Loading branch information
dreiss authored and facebook-github-bot committed Dec 27, 2019
1 parent 495d89d commit f1a336c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions first-party/fbjni/cxx/fbjni/detail/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ struct jtype_traits {
public:
// The jni type signature (described at
// http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html).
static constexpr decltype(descriptor()) /* detail::SimpleFixedString<_> */ kDescriptor = descriptor();
static constexpr decltype(jtype_traits<T>::descriptor()) /* detail::SimpleFixedString<_> */ kDescriptor = descriptor();

// The signature used for class lookups. See
// http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getName().
static constexpr decltype(base_name()) /* detail::SimpleFixedString<_> */ kBaseName = base_name();
static constexpr decltype(jtype_traits<T>::base_name()) /* detail::SimpleFixedString<_> */ kBaseName = base_name();
};

template <typename T>
Expand Down
9 changes: 8 additions & 1 deletion first-party/fbjni/cxx/fbjni/detail/SimpleFixedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@
#pragma once

#include <cassert>
#include <cstring>
#include <stdexcept>
#include <string>
#include <utility>

#if defined(__has_feature)
#define FBJNI_HAS_FEATURE(...) __has_feature(__VA_ARGS__)
#else
#define FBJNI_HAS_FEATURE(...) 0
#endif

namespace facebook {
namespace jni {

Expand Down Expand Up @@ -50,7 +57,7 @@ static_assert(
"Someone appears to have broken constexpr_strlen...");

constexpr size_t constexpr_strlen(const char* s) {
#if defined(__has_feature) && __has_feature(cxx_constexpr_string_builtins)
#if FBJNI_HAS_FEATURE(cxx_constexpr_string_builtins)
// clang provides a constexpr builtin
return __builtin_strlen(s);
#elif defined(__GNUC__) && !defined(__clang__)
Expand Down

0 comments on commit f1a336c

Please sign in to comment.