Skip to content

Commit 2fb2d08

Browse files
ArutyunovGfacebook-github-bot
authored andcommitted
caffe2_benchmark msvc build fix (pytorch#15619)
Summary: Fixing error in caffe2_benchmark binary ``` 2018-12-29T14:09:59.7867995Z d:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.h(90): error C2678: binary '|=': no operator found which takes a left-hand operand of type 'std::_Iosb<int>::_Openmode' (or there is no acceptable conversion) (compiling source file D:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.cc) [D:\a\1\s\caffe2_builders\v141\pytorch\build\Release\binaries\caffe2_benchmark.vcxproj] 2018-12-29T14:09:59.7868252Z d:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.h(92): error C2678: binary '|=': no operator found which takes a left-hand operand of type 'std::_Iosb<int>::_Openmode' (or there is no acceptable conversion) (compiling source file D:\a\1\s\caffe2_builders\v141\pytorch\binaries\benchmark_helper.cc) [D:\a\1\s\caffe2_builders\v141\pytorch\build\Release\binaries\caffe2_benchmark.vcxproj] ``` Pull Request resolved: pytorch#15619 Differential Revision: D13580195 Pulled By: soumith fbshipit-source-id: b0a4479cd5f7555801b1977aeee96b6433293da7
1 parent a918f1d commit 2fb2d08

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

binaries/benchmark_helper.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ void writeTextOutput(
8585
str.pop_back();
8686
lines.push_back(str);
8787

88-
auto flags = std::ios::out;
88+
// static casts are workaround for MSVC build
89+
auto flags = static_cast<std::ios_base::openmode>(std::ios::out);
8990
if (index != 0) {
90-
flags |= std::ios::app;
91+
flags |= static_cast<std::ios_base::openmode>(std::ios::app);
9192
} else {
92-
flags |= std::ios::trunc;
93+
flags |= static_cast<std::ios_base::openmode>(std::ios::trunc);
9394
}
9495
std::ofstream output_file(output_name, flags);
9596
std::ostream_iterator<std::string> output_iterator(output_file, "\n");

0 commit comments

Comments
 (0)