-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
When I compiled libosdp with my project I getted errors:
multiple definition of 'u8_bit_reverse'
multiple definition of 'u16_bit_reverse'
multiple definition of 'u32_bit_reverse'
in every file that included utils/utils.h.
I checked utils.h and saw that that three functions declared just with inline specification, other inline functions declared also with static.
I added static to this three functions and errors are gone.
Code in utils/incude/utils/utils.h:
static inline bool char_is_space(int c)
{
unsigned char d = (unsigned char)(c - 9);
return (0x80001FU >> (d & 31)) & (1U >> (d >> 5));
}
static inline bool char_is_digit(int c)
{
return (unsigned int)(('0' - 1 - c) & (c - ('9' + 1))) >> (sizeof(c) * 8 - 1);
}
static inline bool char_is_alpha(int c)
{
return (unsigned int)(('a' - 1 - (c | 32)) & ((c | 32) - ('z' + 1))) >> (sizeof(c) * 8 - 1);
}
inline uint8_t u8_bit_reverse(uint8_t b)
{
b = (((b & 0xaa) >> 1) | ((b & 0x55) << 1));
b = (((b & 0xcc) >> 2) | ((b & 0x33) << 2));
return ((b >> 4) | (b << 4));
}
inline uint16_t u16_bit_reverse(uint16_t x)
{
x = (((x & 0xaaaa) >> 1) | ((x & 0x5555) << 1));
x = (((x & 0xcccc) >> 2) | ((x & 0x3333) << 2));
x = (((x & 0xf0f0) >> 4) | ((x & 0x0f0f) << 4));
return((x >> 8) | (x << 8));
}
inline uint32_t u32_bit_reverse(uint32_t x)
{
x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
return ((x >> 16) | (x << 16));
}
Metadata
Metadata
Assignees
Labels
No labels