Skip to content

Commit

Permalink
Windows fixes (#138)
Browse files Browse the repository at this point in the history
* * Working on fixing code portability issues for Visual Studio
* Fixing capnp build-related files for Windows

* * Fixed an error in Double with unknown implicit conversion

* * Updated gitignore to not include the .user file

* * Accidentally commented out sections to debug compile errors in VS
* Updated spacing in using_capnp.mpb

* * Updating using_capnp.mpb to use the git repo instead of the zip

* * Moved whatever is going on in the using_boost file (probably for
Android into the non-Windows section)

* * Removing a warning regarding type conversion

* * Fixed some warnings when compiling all tests in Windows
* Fixed errors related to CircularBuffer usage in Windows
  • Loading branch information
jredmondson committed Mar 10, 2019
1 parent 5880bea commit 225d38f
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lib*
*.log
.vimrc
*.vcxproj
*.vcxproj.user
*.vcxproj.filters
*.capnp.*
MADARA.VC.VC.opendb
Expand Down
4 changes: 2 additions & 2 deletions Madara.mpc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project (Madara) : build_files, using_splice, splice_transport, using_ndds, mada
prebuild = perl $(MADARA_ROOT)/bin/generate_version_include.pl

specific(prop:microsoft) {
DisableSpecificWarnings += 4005 4251 4275 4244
DisableSpecificWarnings += 4005 4251 4275 4244 4297
macros += _CRT_SECURE_NO_WARNINGS
}

Expand Down Expand Up @@ -107,7 +107,7 @@ project (Madara) : build_files, using_splice, splice_transport, using_ndds, mada
include/madara/transport/MessageHeader.h
include/madara/transport/PacketScheduler.h
include/madara/transport/ReducedMessageHeader.h
include/madara/transport/SharedMemoryPush.cpp
include/madara/transport/SharedMemoryPush.h
include/madara/transport/QoSTransportSettings.h
include/madara/transport/Transport.h
include/madara/transport/TransportSettings.h
Expand Down
2 changes: 1 addition & 1 deletion include/madara/expression/CompositeModulusNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ madara::expression::CompositeModulusNode::prune(bool& can_change)
delete this->right_;
this->right_ = new LeafNode(*(this->logger_), right_value);

if (right_value == madara::knowledge::KnowledgeRecord::Integer(0))
if (right_value.is_false())
{
madara_logger_ptr_log(logger_, logger::LOG_ERROR,
"KARL COMPILE ERROR: Modulus results in permanent divide by "
Expand Down
3 changes: 2 additions & 1 deletion include/madara/knowledge/CapnObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ struct NoThrowDestruct : T
{
using T::T;

~NoThrowDestruct() noexcept try
~NoThrowDestruct() noexcept
try
{
return;
}
Expand Down
6 changes: 3 additions & 3 deletions include/madara/knowledge/CheckpointPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ std::pair<std::string, KnowledgeRecord> CheckpointReader::next()
void CheckpointPlayer::thread_main(CheckpointPlayer* self)
{
uint64_t start_time = utility::get_time();
uint64_t first_toi = -1UL;
uint64_t prev_toi = -1UL;
uint64_t first_toi = 0UL - 1;
uint64_t prev_toi = 0UL - 1;

while (self->keep_running_.test_and_set())
{
Expand All @@ -469,7 +469,7 @@ void CheckpointPlayer::thread_main(CheckpointPlayer* self)
" record has toi %lu. prev: %lu. first: %lu,. start: %lu\n",
cur_toi, prev_toi, first_toi, start_time);

if (first_toi == -1UL)
if (first_toi == 0UL - 1)
{
first_toi = cur_toi;
prev_toi = first_toi;
Expand Down
2 changes: 1 addition & 1 deletion include/madara/knowledge/KnowledgeRecord.inl
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ inline uint32_t KnowledgeRecord::size(void) const
{
if (any_value_->supports_size())
{
return any_value_->size();
return (uint32_t)any_value_->size();
}
}
else if (type_ == BUFFER)
Expand Down
3 changes: 2 additions & 1 deletion include/madara/knowledge/containers/CircularBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <vector>
#include <string>
#include "madara/MadaraExport.h"
#include "madara/LockType.h"
#include "madara/knowledge/KnowledgeBase.h"
#include "madara/knowledge/ThreadSafeContext.h"
Expand All @@ -29,7 +30,7 @@ namespace containers
* @brief This container stores a thread-safe circular buffer with O(1)
* access times.
*/
class MADARA_EXPORT CircularBuffer
class CircularBuffer
{
public:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace containers
* all operations in CircularBufferConsumer use a local index into the
* CircularBuffer and encourage one-time access of buffer elements.
*/
class MADARA_EXPORT CircularBufferConsumer
class CircularBufferConsumer
{
public:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace containers
* CircularBuffer and encourage one-time access of buffer elements.
*/
template<typename T>
class MADARA_EXPORT CircularBufferConsumerT
class CircularBufferConsumerT
{
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion include/madara/knowledge/containers/CircularBufferT.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace containers
* access times.
*/
template<typename T>
class MADARA_EXPORT CircularBufferT
class CircularBufferT
{
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion include/madara/knowledge/containers/Double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ bool madara::knowledge::containers::Double::operator==(type value) const
{
ContextGuard context_guard(*context_);
MADARA_GUARD_TYPE guard(mutex_);
return context_->get(variable_, settings_) == value;
return context_->get(variable_, settings_).to_double() == value;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion include/madara/knowledge/containers/Integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ inline bool madara::knowledge::containers::Integer::operator==(type value) const
{
ContextGuard context_guard(*context_);
MADARA_GUARD_TYPE guard(mutex_);
return context_->get(variable_, settings_) == value;
return context_->get(variable_, settings_).to_integer() == value;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void NativeCircularBufferConsumer::check_context(const char* func) const

inline NativeCircularBufferConsumer::NativeCircularBufferConsumer(
const std::string& name, KnowledgeBase& knowledge)
: context_(&(knowledge.get_context())), local_index_(-1UL)
: context_(&(knowledge.get_context())), local_index_(0UL - 1)
{
check_name(__func__, name.c_str());

Expand All @@ -63,7 +63,7 @@ inline NativeCircularBufferConsumer::NativeCircularBufferConsumer(

inline NativeCircularBufferConsumer::NativeCircularBufferConsumer(
const std::string& name, Variables& knowledge)
: context_(knowledge.get_context()), local_index_(-1UL)
: context_(knowledge.get_context()), local_index_(0UL - 1)
{
check_name(__func__, name.c_str());

Expand Down
7 changes: 4 additions & 3 deletions include/madara/utility/SupportTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ inline namespace core
template<class T>
struct type
{
type() = default;
using self = T;
};

Expand Down Expand Up @@ -314,10 +315,10 @@ MADARA_AUTORET_REF_FUNC(invoke_, (Func func, Arg0&& arg0, Args&&... args),
template<typename Func, typename... Args>
MADARA_AUTORET_REF_FUNC(
invoke_, (Func func, Args&&... args), func(std::forward<Args>(args)...))
}
}
} // namespace core
} // namespace utility

using namespace utility::core;
}
} // namespace madara

#endif
8 changes: 4 additions & 4 deletions tests/rcw/test_rcw_tracked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ int main(int, char**)
hello_out = "";

KnowledgeRecord empty_record;
test_eq(empty_record == NULL, true);
test_eq(knowledge_cast(1) == NULL, false);
test_eq(knowledge_cast(0) == NULL, true);
test_eq(knowledge_cast(0) == nullptr, true);
test_eq((bool)(empty_record == NULL), true);
test_eq((bool)(knowledge_cast(1) == NULL), false);
test_eq((bool)(knowledge_cast(0) == NULL), true);
test_eq((bool)(knowledge_cast(0) == nullptr), true);

// Two-param version should not have explicit type given
// test_eq(hello, knowledge_cast<std::string>(knowledge_cast(hello),
Expand Down
12 changes: 6 additions & 6 deletions tests/test_circular_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace utility;
using namespace containers;

template<typename T>
std::ostream& operator<<(std::ostream& o, const CircularBuffer<T>& buf)
std::ostream& operator<<(std::ostream& o, const utility::CircularBuffer<T>& buf)
{
for (const auto& cur : buf)
{
Expand All @@ -27,7 +27,7 @@ std::ostream& operator<<(std::ostream& o, const CircularBuffer<T>& buf)

void test_circular_int_buffer()
{
CircularBuffer<int> b(10);
utility::CircularBuffer<int> b(10);

VAL(b.capacity());

Expand Down Expand Up @@ -82,18 +82,18 @@ void test_circular_int_buffer()
std::cout << b << std::endl;

for (auto iter =
std::reverse_iterator<typename CircularBuffer<int>::iterator>(
std::reverse_iterator<typename utility::CircularBuffer<int>::iterator>(
b.end());
iter !=
std::reverse_iterator<typename CircularBuffer<int>::iterator>(b.begin());
std::reverse_iterator<typename utility::CircularBuffer<int>::iterator>(b.begin());
++iter)
{
std::cout << *iter << std::endl;
}
std::cout << std::endl;

{
CircularBuffer<KnowledgeRecord> empty(10);
utility::CircularBuffer<KnowledgeRecord> empty(10);
}
}

Expand Down Expand Up @@ -332,7 +332,7 @@ int main(int, char**)
{
madara::logger::global_logger->set_level(2);

std::cerr << "Test CircularBuffer directly" << std::endl;
std::cerr << "Test utility::CircularBuffer directly" << std::endl;
test_circular_int_buffer();

std::cerr << "Test KnowledgeRecord with history" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_knowledge_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int, char**)
madara::knowledge::KnowledgeBase* knowledge1 =
new madara::knowledge::KnowledgeBase(
"", madara::transport::Types::NO_TRANSPORT);
TEST_NE((unsigned long)knowledge1, (unsigned long)NULL);
TEST_NE(knowledge1, (madara::knowledge::KnowledgeBase*)NULL);
// Terminal failure lets get out of her..
if (knowledge1 == NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions using_boost.mpb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
project {
libpaths += /usr/local/lib
libpaths += /usr/local/Cellar/boost@1.59/1.59.0/lib
includes += /usr/local/Cellar/boost@1.59/1.59.0/include


expand(BOOST_ROOT_LIB) {
Expand Down Expand Up @@ -50,5 +47,8 @@ project {
// end if windows build
} else {
lit_libs += $(BOOST_STATIC_LIB_PREFIX)boost_system$(BOOST_CFG)
libpaths += /usr/local/lib
libpaths += /usr/local/Cellar/boost@1.59/1.59.0/lib
includes += /usr/local/Cellar/boost@1.59/1.59.0/include
}
}
23 changes: 16 additions & 7 deletions using_capnp.mpb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
project {
includes += $(CAPNP_ROOT)/c++/src
libpaths += $(CAPNP_ROOT)/c++/.libs

libs += capnp
libs += capnp-json
libs += kj

Define_Custom (CAPN) {
command = bash -c "capnp compile -I \$$CAPNP_ROOT/c++/src -oc++ \"\$$0\";\
Expand All @@ -16,9 +10,24 @@ capnp compile -I \$$CAPNP_ROOT/c++/src -o/bin/cat \"\$$0\" > \$$0.bin"
generic_outputext = .capnp.bin
}

includes += $(CAPNP_ROOT)/c++/src

specific(prop:microsoft) {
DisableSpecificWarnings += 4005 4251 4275 4244
DisableSpecificWarnings += 4005 4251 4275 4244 4267
macros += _CRT_SECURE_NO_WARNINGS

Debug::libpaths += $(CAPNP_ROOT)/c++/src/capnp/Debug $(CAPNP_ROOT)/c++/src/kj/Debug
Release::libpaths += $(CAPNP_ROOT)/c++/src/capnp/Release $(CAPNP_ROOT)/c++/src/kj/Release

lit_libs += capnp
lit_libs += capnp-json
lit_libs += kj
} else {
libpaths += $(CAPNP_ROOT)/c++/.libs

libs += capnp
libs += capnp-json
libs += kj
}

verbatim(make, top) {
Expand Down

0 comments on commit 225d38f

Please sign in to comment.