mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This PR is to address an issue we're seeing compiling flutter+impeller in certain configurations. Specifically: 1. Compiling with `clang-15` 2. using the GCC 13 backend to provide headers and cstdlib. Via the `clang-15` version flag: ``` clang-15 -v Debian clang version 15.0.7 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 ``` We were building using the gcc 12 backend for a while, but picked up an update that forced us to 13, and then saw this issue. The issue is seen as `uint8_t` being undefined as in the following partial messages: ``` hex_codec.cc:18:5: error: unknown type name 'uint8_t' base32.cc:29:32: error: unknown type name 'uint8_t' ``` I'm not sure this is the cleanest fix, or if it might be better handled by adding some compile time switches, but I wanted to provide this to start conversation. I'm also hoping to get a better idea of tests run against a PR. If there's any I should run manually we can discuss that here. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
26 lines
621 B
C++
26 lines
621 B
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/fml/base32.h"
|
|
|
|
#include <cstdint> // uint8_t
|
|
#include <string>
|
|
|
|
namespace fml {
|
|
|
|
static constexpr char kEncoding[] = "0123456789abcdef";
|
|
|
|
std::string HexEncode(std::string_view input) {
|
|
std::string result;
|
|
result.reserve(input.size() * 2);
|
|
for (char c : input) {
|
|
uint8_t b = static_cast<uint8_t>(c);
|
|
result.push_back(kEncoding[b >> 4]);
|
|
result.push_back(kEncoding[b & 0xF]);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
} // namespace fml
|