From 62e2b3c7500dd221e9be0787af22bce68f4ffdb1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 2 Mar 2016 21:10:24 +0000 Subject: [PATCH] Changes for GCC compatibility --- src/checksum.h | 19 +++++++------ src/crc16.h | 8 +++--- src/crc16_ccitt.h | 10 +++---- src/crc16_kermit.h | 10 +++---- src/crc32.h | 8 +++--- src/crc64_ecma.h | 8 +++--- src/crc8_ccitt.h | 10 +++---- src/forward_list.h | 4 +-- src/intrusive_forward_list.h | 22 ++++++++------- src/intrusive_links.h | 52 ++++++++++++++++++------------------ src/iunordered_map.h | 12 ++++----- src/ivector.h | 9 ++++++- src/list.h | 8 +++--- src/vector.h | 12 ++++----- 14 files changed, 100 insertions(+), 92 deletions(-) diff --git a/src/checksum.h b/src/checksum.h index 154b68a0..b6bb0ee4 100644 --- a/src/checksum.h +++ b/src/checksum.h @@ -122,7 +122,7 @@ namespace etl //************************************************************************* checksum() { - reset(); + this->reset(); } //************************************************************************* @@ -133,8 +133,8 @@ namespace etl template checksum(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; @@ -151,7 +151,7 @@ namespace etl //************************************************************************* bsd_checksum() { - reset(); + this->reset(); } //************************************************************************* @@ -162,8 +162,8 @@ namespace etl template bsd_checksum(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; @@ -180,7 +180,7 @@ namespace etl //************************************************************************* xor_checksum() { - reset(); + this->reset(); } //************************************************************************* @@ -191,11 +191,10 @@ namespace etl template xor_checksum(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; - } #endif diff --git a/src/crc16.h b/src/crc16.h index 3d0f02b4..5c20f6d1 100644 --- a/src/crc16.h +++ b/src/crc16.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc16 16 bit CRC calculation @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc16() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc16(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/crc16_ccitt.h b/src/crc16_ccitt.h index 2f52cfcb..e991bc8c 100644 --- a/src/crc16_ccitt.h +++ b/src/crc16_ccitt.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc16_ccitt 16 bit CRC CCITT calculation @@ -50,7 +50,7 @@ namespace etl /// \ingroup crc16_ccitt //*************************************************************************** extern const uint16_t CRC_CCITT[]; - + //*************************************************************************** /// CRC16 CCITT policy. /// Calculates CRC16 CCITT using polynomial 0x1021 @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc16_ccitt() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc16_ccitt(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/crc16_kermit.h b/src/crc16_kermit.h index e635fa0f..5334054b 100644 --- a/src/crc16_kermit.h +++ b/src/crc16_kermit.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc16_kermit 16 bit CRC Kermit calculation @@ -50,7 +50,7 @@ namespace etl /// \ingroup crc //*************************************************************************** extern const uint16_t CRC_KERMIT[]; - + //*************************************************************************** /// CRC16 Kermit policy. /// Calculates CRC16 Kermit using polynomial 0x1021 @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc16_kermit() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc16_kermit(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/crc32.h b/src/crc32.h index 95d896f2..43412ee5 100644 --- a/src/crc32.h +++ b/src/crc32.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc32 32 bit CRC calculation @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc32() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc32(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/crc64_ecma.h b/src/crc64_ecma.h index 679b0acb..a97c81c3 100644 --- a/src/crc64_ecma.h +++ b/src/crc64_ecma.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc64_ecma 64 bit CRC ECMA calculation @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc64_ecma() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc64_ecma(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/crc8_ccitt.h b/src/crc8_ccitt.h index 5168acad..0a4721bc 100644 --- a/src/crc8_ccitt.h +++ b/src/crc8_ccitt.h @@ -37,7 +37,7 @@ SOFTWARE. #include "frame_check_sequence.h" #if defined(COMPILER_KEIL) -#pragma diag_suppress 1300 +#pragma diag_suppress 1300 #endif ///\defgroup crc8_ccitt 8 bit CRC calculation @@ -73,7 +73,7 @@ namespace etl { return crc; } - }; + }; //************************************************************************* /// CRC8 CCITT @@ -87,7 +87,7 @@ namespace etl //************************************************************************* crc8_ccitt() { - reset(); + this->reset(); } //************************************************************************* @@ -98,8 +98,8 @@ namespace etl template crc8_ccitt(TIterator begin, const TIterator end) { - reset(); - add(begin, end); + this->reset(); + this->add(begin, end); } }; } diff --git a/src/forward_list.h b/src/forward_list.h index ea61e215..8ca61191 100644 --- a/src/forward_list.h +++ b/src/forward_list.h @@ -77,10 +77,10 @@ namespace etl //************************************************************************* /// Construct from size and value. //************************************************************************* - explicit forward_list(size_t initialSize, typename iforward_list::parameter_t value = T()) + explicit forward_list(size_t initial_size, typename iforward_list::parameter_t value = T()) : iforward_list(node_pool, MAX_SIZE) { - iforward_list::assign(initialSize, value); + iforward_list::assign(initial_size, value); } //************************************************************************* diff --git a/src/intrusive_forward_list.h b/src/intrusive_forward_list.h index 04260181..4546b8a7 100644 --- a/src/intrusive_forward_list.h +++ b/src/intrusive_forward_list.h @@ -76,7 +76,7 @@ namespace etl intrusive_forward_list_empty(string_type file_name, numeric_type line_number) : intrusive_forward_list_exception(ETL_ERROR_TEXT("intrusive_forward_list:empty", ETL_FILE"A"), file_name, line_number) - { + { } }; @@ -845,7 +845,7 @@ namespace etl { iterator i_item = begin(); iterator i_last_item = before_begin(); - + while (i_item != end()) { if (predicate(*i_item)) @@ -1056,18 +1056,20 @@ namespace etl private: link_type start_link; ///< The link that acts as the intrusive_forward_list start. - + //************************************************************************* /// Counter type based on count option. //************************************************************************* - template - class counter_type; + template + class counter_type + { + }; //************************************************************************* /// Slow type. //************************************************************************* - template <> - class counter_type + template + class counter_type { public: @@ -1100,8 +1102,8 @@ namespace etl //************************************************************************* /// Fast type. //************************************************************************* - template <> - class counter_type + template + class counter_type { public: @@ -1144,7 +1146,7 @@ namespace etl }; counter_type current_size; ///< Counts the number of elements in the list. - + //************************************************************************* /// Is the intrusive_forward_list a trivial length? //************************************************************************* diff --git a/src/intrusive_links.h b/src/intrusive_links.h index 2f4f4e5f..f72e99a7 100644 --- a/src/intrusive_links.h +++ b/src/intrusive_links.h @@ -74,7 +74,7 @@ namespace etl } //*************************************************************************** - /// Link exception. + /// Link exception. //*************************************************************************** class link_exception : public etl::exception { @@ -87,7 +87,7 @@ namespace etl }; //*************************************************************************** - /// not unlinked exception. + /// not unlinked exception. //*************************************************************************** class not_unlinked_exception : public etl::link_exception { @@ -131,7 +131,7 @@ namespace etl /// A forward link. //*************************************************************************** template - struct forward_link + struct forward_link : public __private_intrusive_links__::forward_link_base, ID_, OPTION_> { }; @@ -145,7 +145,7 @@ namespace etl { forward_link() { - clear(); + this->clear(); } }; @@ -160,12 +160,12 @@ namespace etl { forward_link() { - clear(); + this->clear(); } ~forward_link() { - assert(etl_next != nullptr); + assert(this->etl_next != nullptr); } }; @@ -279,7 +279,7 @@ namespace etl else { last.etl_next = nullptr; - } + } } // Reference @@ -369,12 +369,12 @@ namespace etl /// A bidirectional link. //*************************************************************************** template - struct bidirectional_link + struct bidirectional_link : public __private_intrusive_links__::bidirectional_link_base, ID_, OPTION_> { void unlink() { - base_unlink(); + this->base_unlink(); } }; @@ -383,23 +383,23 @@ namespace etl // When this link is destroyed it will automatically unlink itself. //****************************************************************** template - struct bidirectional_link + struct bidirectional_link : public __private_intrusive_links__::bidirectional_link_base, ID_, etl::link_option::AUTO> { bidirectional_link() { - clear(); + this->clear(); } ~bidirectional_link() { - base_unlink(); + this->base_unlink(); } void unlink() { - base_unlink(); - clear(); + this->base_unlink(); + this->clear(); } }; @@ -409,24 +409,24 @@ namespace etl // is destroyed. //****************************************************************** template - struct bidirectional_link + struct bidirectional_link : public __private_intrusive_links__::bidirectional_link_base, ID_, etl::link_option::CHECKED> { bidirectional_link() { - clear(); + this->clear(); } ~bidirectional_link() { - assert(etl_previous == nullptr); - assert(etl_next == nullptr); + assert(this->etl_previous == nullptr); + assert(this->etl_next == nullptr); } void unlink() { - base_unlink(); - clear(); + this->base_unlink(); + this->clear(); } }; @@ -696,7 +696,7 @@ namespace etl { tree_link() { - clear(); + this->clear(); } }; @@ -711,14 +711,14 @@ namespace etl { tree_link() { - clear(); + this->clear(); } ~tree_link() { - assert(etl_parent != nullptr); - assert(etl_left != nullptr); - assert(etl_right != nullptr); + assert(this->etl_parent != nullptr); + assert(this->etl_left != nullptr); + assert(this->etl_right != nullptr); } }; @@ -822,4 +822,4 @@ namespace etl } #undef ETL_FILE -#endif \ No newline at end of file +#endif diff --git a/src/iunordered_map.h b/src/iunordered_map.h index d4e6260a..7c2b333b 100644 --- a/src/iunordered_map.h +++ b/src/iunordered_map.h @@ -700,10 +700,10 @@ namespace etl const mapped_type& at(key_value_parameter_t key) const { // Find the bucket. - bucket_list_t::const_iterator ibucket = pbuckets->begin() + bucket(key); + typename bucket_list_t::const_iterator ibucket = pbuckets->begin() + bucket(key); // Find the first node in the bucket. - bucket_t::const_iterator inode = ibucket->begin(); + typename bucket_t::const_iterator inode = ibucket->begin(); // Walk the list looking for the right one. while (inode != ibucket->end()) @@ -1049,8 +1049,8 @@ namespace etl //********************************************************************* /// Returns a range containing all elements with key key in the container. - /// The range is defined by two iterators, the first pointing to the first - /// element of the wanted range and the second pointing past the last + /// The range is defined by two iterators, the first pointing to the first + /// element of the wanted range and the second pointing past the last /// element of the range. ///\param key The key to search for. ///\return An iterator pair to the range of elements if the key exists, otherwise end(). @@ -1070,8 +1070,8 @@ namespace etl //********************************************************************* /// Returns a range containing all elements with key key in the container. - /// The range is defined by two iterators, the first pointing to the first - /// element of the wanted range and the second pointing past the last + /// The range is defined by two iterators, the first pointing to the first + /// element of the wanted range and the second pointing past the last /// element of the range. ///\param key The key to search for. ///\return A const iterator pair to the range of elements if the key exists, otherwise end(). diff --git a/src/ivector.h b/src/ivector.h index 68a9adbf..2245a027 100644 --- a/src/ivector.h +++ b/src/ivector.h @@ -193,7 +193,7 @@ namespace etl //********************************************************************* void resize(size_t new_size) { - ETL_ASSERT(new_size <= MAX_SIZE, ETL_ERROR(vector_full)); + //ETL_ASSERT(new_size <= MAX_SIZE, ETL_ERROR(vector_full)); // Size up or size down? if (new_size > current_size) @@ -273,6 +273,13 @@ namespace etl reference at(size_t i) { ETL_ASSERT(i < current_size, ETL_ERROR(vector_out_of_bounds)); + +// if (i >= current_size) +// { +// +// throw etl::vector_out_of_bounds("a", 1); +// } + return p_buffer[i]; } diff --git a/src/list.h b/src/list.h index 28a52426..361d1a87 100644 --- a/src/list.h +++ b/src/list.h @@ -77,19 +77,19 @@ namespace etl //************************************************************************* /// Construct from size. //************************************************************************* - explicit list(size_t initialSize) + explicit list(size_t initial_size) : ilist(node_pool, MAX_SIZE) { - ilist::assign(initialSize, T()); + ilist::assign(initial_size, T()); } //************************************************************************* /// Construct from size and value. //************************************************************************* - list(size_t initialSize, typename ilist::parameter_t value) + list(size_t initial_size, typename ilist::parameter_t value) : ilist(node_pool, MAX_SIZE) { - ilist::assign(initialSize, value); + ilist::assign(initial_size, value); } //************************************************************************* diff --git a/src/vector.h b/src/vector.h index 46e61d9b..274fd48b 100644 --- a/src/vector.h +++ b/src/vector.h @@ -72,25 +72,25 @@ namespace etl //************************************************************************* /// Constructor, with size. - ///\param initialSize The initial size of the vector. + ///\param initial_size The initial size of the vector. //************************************************************************* - explicit vector(size_t initialSize) + explicit vector(size_t initial_size) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { ivector::initialise(); - ivector::resize(initialSize); + ivector::resize(initial_size); } //************************************************************************* /// Constructor, from initial size and value. - ///\param initialSize The initial size of the vector. + ///\param initial_size The initial size of the vector. ///\param value The value to fill the vector with. //************************************************************************* - vector(size_t initialSize, typename ivector::parameter_t value) + vector(size_t initial_size, typename ivector::parameter_t value) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { ivector::initialise(); - ivector::resize(initialSize, value); + ivector::resize(initial_size, value); } //*************************************************************************