Skip to content

Commit da2befe

Browse files
Ivan ShynkarenkaIvan Shynkarenka
authored andcommitted
"fbe.h" windows header file problem hope to modify #67
1 parent 4580656 commit da2befe

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

include/generator_cpp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class GeneratorCpp : public Generator
4949
void GenerateWarningsFooter();
5050
void GenerateFooter();
5151
void GenerateImports();
52+
void GenerateImportsSource();
5253
void GenerateImports(const std::string& source);
5354
void GenerateImports(const std::shared_ptr<Package>& p);
5455
void GenerateImportsModels(const std::shared_ptr<Package>& p, bool final);

proto/fbe.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
#include "fbe.h"
99

10+
#if defined(_WIN32) || defined(_WIN64)
11+
#include <windows.h>
12+
#undef DELETE
13+
#undef ERROR
14+
#undef HOST_NOT_FOUND
15+
#undef Yield
16+
#undef min
17+
#undef max
18+
#undef uuid_t
19+
#endif
20+
1021
namespace FBE {
1122

1223
std::string buffer_t::base64encode() const

proto/fbe.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <uuid/uuid.h>
4444
#undef HOST_NOT_FOUND
4545
#elif defined(_WIN32) || defined(_WIN64)
46-
#include <windows.h>
4746
#undef DELETE
4847
#undef ERROR
4948
#undef HOST_NOT_FOUND

source/generator_cpp.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ void GeneratorCpp::GenerateImports()
194194
#include <uuid/uuid.h>
195195
#undef HOST_NOT_FOUND
196196
#elif defined(_WIN32) || defined(_WIN64)
197-
#include <windows.h>
198197
#undef DELETE
199198
#undef ERROR
200199
#undef HOST_NOT_FOUND
@@ -219,6 +218,27 @@ void GeneratorCpp::GenerateImports()
219218
}
220219
}
221220

221+
void GeneratorCpp::GenerateImportsSource()
222+
{
223+
std::string code = R"CODE(
224+
#if defined(_WIN32) || defined(_WIN64)
225+
#include <windows.h>
226+
#undef DELETE
227+
#undef ERROR
228+
#undef HOST_NOT_FOUND
229+
#undef Yield
230+
#undef min
231+
#undef max
232+
#undef uuid_t
233+
#endif
234+
)CODE";
235+
236+
// Prepare code template
237+
code = std::regex_replace(code, std::regex("\n"), EndLine());
238+
239+
Write(code);
240+
}
241+
222242
void GeneratorCpp::GenerateImports(const std::string& source)
223243
{
224244
WriteLine();
@@ -6332,6 +6352,9 @@ void GeneratorCpp::GenerateFBE_Source(const CppCommon::Path& path)
63326352
// Generate imports
63336353
GenerateImports("fbe.h");
63346354

6355+
// Generate imports source
6356+
GenerateImportsSource();
6357+
63356358
// Generate namespace begin
63366359
WriteLine();
63376360
WriteLineIndent("namespace FBE {");

0 commit comments

Comments
 (0)