Skip to content

Commit a3e3386

Browse files
committed
fix compilation on windows
1 parent e426dcd commit a3e3386

File tree

16 files changed

+263
-144
lines changed

16 files changed

+263
-144
lines changed

3rdparty/backward-cpp/backward.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ class StackTraceImplHolder: public StackTraceImplBase {
680680
};
681681

682682

683+
#ifndef BACKWARD_SYSTEM_UNKNOWN
683684
#if BACKWARD_HAS_UNWIND == 1
684685

685686
namespace details {
@@ -780,7 +781,7 @@ class StackTraceImpl<system_tag::current_tag>: public StackTraceImplHolder {
780781
};
781782

782783

783-
#else // BACKWARD_HAS_UNWIND == 0
784+
#else // BACKWARD_HAS_UNWIND == 0
784785

785786
template <>
786787
class StackTraceImpl<system_tag::current_tag>: public StackTraceImplHolder {
@@ -816,6 +817,7 @@ class StackTraceImpl<system_tag::current_tag>: public StackTraceImplHolder {
816817
};
817818

818819
#endif // BACKWARD_HAS_UNWIND
820+
#endif //BACKWARD_SYSTEM_UNKNOWN
819821

820822
class StackTrace:
821823
public StackTraceImpl<system_tag::current_tag> {};

3rdparty/coroutine/coroutine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ inline void destroy(routine_t id)
134134
ordinator.indexes.push_back(id);
135135
}
136136

137-
inline void __stdcall entry(LPVOID lpParameter)
137+
inline void __stdcall entry(LPVOID )
138138
{
139139
routine_t id = ordinator.current;
140140
Routine *routine = ordinator.routines[id-1];

3rdparty/minitrace/minitrace.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inline int64_t mtr_time_usec(){
8484
}
8585
__int64 time;
8686
QueryPerformanceCounter((LARGE_INTEGER*)&time);
87-
int64_t now = 1.0e6 * ((double) (time - _starttime) / (double) _frequency);
87+
int64_t now = static_cast<int64_t>( 1.0e6 * ((double)(time - _starttime) / (double)_frequency));
8888
if( now <= prev) now = prev + 1;
8989
prev = now;
9090
return now;
@@ -225,7 +225,6 @@ void mtr_flush() {
225225
#ifndef MTR_ENABLED
226226
return;
227227
#endif
228-
int i = 0;
229228
char linebuf[1024];
230229
char arg_buf[256];
231230
char id_buf[256];
@@ -236,7 +235,7 @@ void mtr_flush() {
236235
int old_tracing = is_tracing;
237236
is_tracing = 0; // Stop logging even if using interlocked increments instead of the mutex. Can cause data loss.
238237

239-
for (i = 0; i < count; i++) {
238+
for (int i = 0; i < count; i++) {
240239
raw_event_t *raw = &buffer[i];
241240
int len;
242241
switch (raw->arg_type) {
@@ -277,13 +276,14 @@ void mtr_flush() {
277276
// On Windows, we often end up with backslashes in category.
278277
{
279278
char temp[256];
280-
int len = (int)strlen(cat);
281-
int i;
282-
if (len > 255) len = 255;
283-
for (i = 0; i < len; i++) {
284-
temp[i] = cat[i] == '\\' ? '/' : cat[i];
279+
int cat_len = (int)strlen(cat);
280+
if (cat_len > 255)
281+
cat_len = 255;
282+
for (int a = 0; a < cat_len; a++)
283+
{
284+
temp[a] = cat[a] == '\\' ? '/' : cat[a];
285285
}
286-
temp[len] = 0;
286+
temp[cat_len] = 0;
287287
cat = temp;
288288
}
289289
#endif
@@ -329,7 +329,7 @@ void internal_mtr_raw_event(const char *category, const char *name, char ph, voi
329329
int64_t x;
330330
memcpy(&x, id, sizeof(int64_t));
331331
ev->ts = x;
332-
ev->a_double = (ts - x);
332+
ev->a_double = static_cast<double>(ts - x);
333333
} else {
334334
ev->ts = ts;
335335
}

3rdparty/minitrace/minitrace.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ class MTRScopedTrace {
220220
private:
221221
const char *category_;
222222
const char *name_;
223-
int64_t start_time_;
223+
int64_t start_time_;
224224
};
225225

226226
// Only outputs a block if execution time exceeded the limit.
227227
// TODO: This will effectively call mtr_time_usec twice at the end, which is bad.
228228
class MTRScopedTraceLimit {
229229
public:
230-
MTRScopedTraceLimit(const char *category, const char *name, double limit_s)
230+
MTRScopedTraceLimit(const char* category, const char* name, int64_t limit_s)
231231
: category_(category), name_(name), limit_(limit_s) {
232232
start_time_ = mtr_time_usec();
233233
}
@@ -241,8 +241,8 @@ class MTRScopedTraceLimit {
241241
private:
242242
const char *category_;
243243
const char *name_;
244-
double start_time_;
245-
double limit_;
244+
int64_t start_time_;
245+
int64_t limit_;
246246
};
247247

248248
class MTRScopedTraceArg {

CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ else()
8484
find_package(GTest)
8585

8686
if(NOT GTEST_FOUND)
87-
message(WARNING " GTest not found!")
87+
message(WARNING " GTest missing!")
8888
endif(NOT GTEST_FOUND)
8989

90-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
91-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
92-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
90+
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
91+
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
92+
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
9393

9494
endif()
9595
if(NOT MSVC)
@@ -109,7 +109,6 @@ list(APPEND BT_SOURCE
109109
src/condition_node.cpp
110110
src/control_node.cpp
111111
src/shared_library.cpp
112-
src/shared_library_UNIX.cpp
113112
src/tree_node.cpp
114113
src/xml_parsing.cpp
115114

@@ -139,8 +138,18 @@ if (NOT backward_ros_FOUND)
139138
endif()
140139

141140
######################################################
141+
if (UNIX)
142+
list(APPEND BT_SOURCE src/shared_library_UNIX.cpp )
143+
add_library(${BEHAVIOR_TREE_LIBRARY} SHARED ${BT_SOURCE} )
144+
endif()
145+
146+
if (WIN32)
147+
list(APPEND BT_SOURCE src/shared_library_WIN.cpp )
148+
add_library(${BEHAVIOR_TREE_LIBRARY} STATIC ${BT_SOURCE} )
149+
endif()
150+
151+
142152

143-
add_library(${BEHAVIOR_TREE_LIBRARY} SHARED ${BT_SOURCE} )
144153
target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PUBLIC
145154
${BEHAVIOR_TREE_EXTERNAL_LIBRARIES})
146155

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 2.8)
22

3+
include_directories( ../sample_nodes )
4+
35

46
# The plugin libdummy_nodes.so can be linked statically or
57
# loaded dynamically at run-time.

include/behaviortree_cpp/bt_factory.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,25 @@ typedef std::function<std::unique_ptr<TreeNode>(const std::string&, const NodeCo
3333
NodeBuilder;
3434

3535
constexpr const char* PLUGIN_SYMBOL = "BT_RegisterNodesFromPlugin";
36+
37+
#ifdef __linux__
38+
3639
#define BT_REGISTER_NODES(factory) \
3740
extern "C" void __attribute__((visibility("default"))) \
38-
BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)
41+
BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)
42+
43+
#elif _WIN32
44+
45+
#ifdef WIN_EXPORT
46+
47+
#define BT_REGISTER_NODES(factory) \
48+
__declspec(dllexport) void BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)
49+
#else
50+
#define BT_REGISTER_NODES(factory) \
51+
static void BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)
52+
#endif
53+
#endif
54+
3955

4056
/**
4157
* @brief Struct used to store a tree.

include/behaviortree_cpp/flatbuffers/bt_flatbuffer_helper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ inline SerializedTransition SerializeTransition(uint16_t UID,
152152
{
153153
using namespace std::chrono;
154154
SerializedTransition buffer;
155-
auto usec = duration_cast<microseconds>(timestamp).count();
156-
uint32_t t_sec = usec / 1000000;
157-
uint32_t t_usec = usec % 1000000;
155+
int64_t usec = duration_cast<microseconds>(timestamp).count();
156+
int64_t t_sec = usec / 1000000;
157+
int64_t t_usec = usec % 1000000;
158158

159159
flatbuffers::WriteScalar(&buffer[0], t_sec);
160160
flatbuffers::WriteScalar(&buffer[4], t_usec);

0 commit comments

Comments
 (0)