Skip to content

Commit c1a0bf3

Browse files
authored
Fixes for Windows (#1603)
* Fix warnings on Windows * Use dynamic C runtime for nanopb
1 parent 8766e5d commit c1a0bf3

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ endif()
169169
# nanopb
170170
set(nanopb_BUILD_GENERATOR ON CACHE BOOL "Enable the nanopb generator")
171171
set(nanopb_PROTOC_PATH ${NANOPB_PROTOC_BIN} CACHE STRING "Protoc location")
172+
set(nanopb_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
172173
add_external_subdirectory(nanopb)
173174

174175
target_compile_definitions(

Firestore/core/src/firebase/firestore/local/local_serializer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ util::StatusOr<QueryData> LocalSerializer::DecodeQueryData(
271271
QueryData LocalSerializer::DecodeQueryData(Reader* reader) const {
272272
if (!reader->status().ok()) return QueryData::Invalid();
273273

274-
int64_t target_id = 0;
274+
model::TargetId target_id = 0;
275275
SnapshotVersion version = SnapshotVersion::None();
276276
std::vector<uint8_t> resume_token;
277277
Query query = Query::Invalid();
@@ -284,7 +284,8 @@ QueryData LocalSerializer::DecodeQueryData(Reader* reader) const {
284284
case firestore_client_Target_target_id_tag:
285285
if (!reader->RequireWireType(PB_WT_VARINT, tag))
286286
return QueryData::Invalid();
287-
target_id = reader->ReadInteger();
287+
// TODO(rsgowman): How to handle truncation of integer types?
288+
target_id = static_cast<model::TargetId>(reader->ReadInteger());
288289
break;
289290

290291
case firestore_client_Target_snapshot_version_tag:

Firestore/core/src/firebase/firestore/local/local_serializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Firestore/core/src/firebase/firestore/model/document.h"
2525
#include "Firestore/core/src/firebase/firestore/model/maybe_document.h"
2626
#include "Firestore/core/src/firebase/firestore/model/no_document.h"
27+
#include "Firestore/core/src/firebase/firestore/model/types.h"
2728
#include "Firestore/core/src/firebase/firestore/nanopb/reader.h"
2829
#include "Firestore/core/src/firebase/firestore/nanopb/writer.h"
2930
#include "Firestore/core/src/firebase/firestore/remote/serializer.h"

Firestore/core/src/firebase/firestore/local/query_data.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using core::Query;
2626
using model::SnapshotVersion;
2727

2828
QueryData::QueryData(Query&& query,
29-
int target_id,
29+
model::TargetId target_id,
3030
QueryPurpose purpose,
3131
SnapshotVersion&& snapshot_version,
3232
std::vector<uint8_t>&& resume_token)

Firestore/core/src/firebase/firestore/local/query_data.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "Firestore/core/src/firebase/firestore/core/query.h"
2424
#include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
25+
#include "Firestore/core/src/firebase/firestore/model/types.h"
2526

2627
namespace firebase {
2728
namespace firestore {
@@ -61,7 +62,7 @@ class QueryData {
6162
* point in time from which the server should resume sending results.
6263
*/
6364
QueryData(core::Query&& query,
64-
int target_id,
65+
model::TargetId target_id,
6566
QueryPurpose purpose,
6667
model::SnapshotVersion&& snapshot_version,
6768
std::vector<uint8_t>&& resume_token);
@@ -83,7 +84,7 @@ class QueryData {
8384
return query_;
8485
}
8586

86-
int target_id() const {
87+
model::TargetId target_id() const {
8788
return target_id_;
8889
}
8990

@@ -104,7 +105,7 @@ class QueryData {
104105

105106
private:
106107
const core::Query query_;
107-
int target_id_;
108+
model::TargetId target_id_;
108109
QueryPurpose purpose_;
109110
const model::SnapshotVersion snapshot_version_;
110111
const std::vector<uint8_t> resume_token_;

Firestore/core/src/firebase/firestore/remote/serializer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ Query Serializer::DecodeQueryTarget(nanopb::Reader* reader) {
703703
}
704704
}
705705

706-
int from_count = query.from.size();
706+
size_t from_count = query.from.size();
707707
if (from_count > 0) {
708708
HARD_ASSERT(
709709
from_count == 1,

Firestore/core/src/firebase/firestore/util/string_win.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ std::string LastErrorMessage(DWORD last_error) {
104104
DWORD output_len = ::FormatMessageW(
105105
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
106106
last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_text.get(),
107-
size, nullptr);
107+
static_cast<DWORD>(size), nullptr);
108108
if (output_len == 0) {
109109
DWORD format_error = ::GetLastError();
110110
return util::StringFormat(

0 commit comments

Comments
 (0)