Hi, I need to calc the crc chunkwise (ie. calc crc of a block, then continue with the next block etc.). Is this (not) possible with the boost crc? In other words: how can the type "crc_32_type" be initialized with a user supplied uint32_t value? boost::crc_32_type crc; crc = 0x1234; // <-- this brings compile error crc.process_bytes(buf, len); error: no match for ‘operator=’ (operand types are ‘boost::crc_32_type {aka boost::crc_optimal<32ul, 79764919u, 4294967295u, 4294967295u, true, true>}’ and ‘const uint32_t {aka const unsigned int}’) Thx
U.Mutlu wrote on 07/09/2015 04:38 PM:
Hi, I need to calc the crc chunkwise (ie. calc crc of a block, then continue with the next block etc.). Is this (not) possible with the boost crc?
In other words: how can the type "crc_32_type" be initialized with a user supplied uint32_t value?
boost::crc_32_type crc; crc = 0x1234; // <-- this brings compile error crc.process_bytes(buf, len);
error: no match for ‘operator=’ (operand types are ‘boost::crc_32_type {aka boost::crc_optimal<32ul, 79764919u, 4294967295u, 4294967295u, true, true>}’ and ‘const uint32_t {aka const unsigned int}’)
I don't understand why the author has used static data members in the class below. Isn't that an indication that this class cannot be used in a multithreaded environment? class boost::crc_optimal { public: // Type typedef implementation_defined value_type; // Constants reflecting template parameters static std::size_t const bit_count = Bits; static value_type const truncated_polynominal = TruncPoly; static value_type const initial_remainder = InitRem; static value_type const final_xor_value = FinalXor; static bool const reflect_input = ReflectIn; static bool const reflect_remainder = ReflectRem; ... http://www.boost.org/doc/libs/1_55_0/libs/crc/crc.html
I don't understand why the author has used static data members in the class below. Isn't that an indication that this class cannot be used in a multithreaded environment?
class boost::crc_optimal { public: // Type typedef implementation_defined value_type;
// Constants reflecting template parameters static std::size_t const bit_count = Bits; static value_type const truncated_polynominal = TruncPoly; static value_type const initial_remainder = InitRem; static value_type const final_xor_value = FinalXor; static bool const reflect_input = ReflectIn; static bool const reflect_remainder = ReflectRem;
static const integer types are all compile-time constants - they're just fine in a multithreaded environment - and IMO this is the correct way to define constants that are known at compile time (albeit C++11 adds constexpr, but it doesn't really change anything in this use case). HTH, John.
U.Mutlu wrote on 07/09/2015 04:38 PM:
Hi, I need to calc the crc chunkwise (ie. calc crc of a block, then continue with the next block etc.). Is this (not) possible with the boost crc?
In other words: how can the type "crc_32_type" be initialized with a user supplied uint32_t value?
boost::crc_32_type crc; crc = 0x1234; // <-- this brings compile error crc.process_bytes(buf, len);
error: no match for ‘operator=’ (operand types are ‘boost::crc_32_type {aka boost::crc_optimal<32ul, 79764919u, 4294967295u, 4294967295u, true, true>}’ and ‘const uint32_t {aka const unsigned int}’)
Problem now solved as follows: uint32_t crc32(const void* Ap, const size_t AuLen, uint32_t& /* IO */ AuInterimResult) { // 2015-07-09-Th // for "crc updating" pass AuInterimResult; must be 0 or 0xFFFFFFFF initially if (!AuInterimResult) AuInterimResult = 0xFFFFFFFF; boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc(AuInterimResult); crc.process_bytes((const char*) Ap, AuLen); AuInterimResult = crc.get_interim_remainder(); return crc.checksum(); }
participants (2)
-
John Maddock
-
U.Mutlu