Skip to content

make typedefs platform independent#105

Open
langchr86 wants to merge 2 commits intowillemt:masterfrom
langchr86:feature/make_typedefs_platform_independent
Open

make typedefs platform independent#105
langchr86 wants to merge 2 commits intowillemt:masterfrom
langchr86:feature/make_typedefs_platform_independent

Conversation

@langchr86
Copy link

No description provided.

@langchr86
Copy link
Author

The coverage check seems to be not relevant because I added 2 new lines (include and new line) which is not covered.

@langchr86
Copy link
Author

langchr86 commented Jan 22, 2020

The purpose of this PR was that I have to serialize and transport the raft packages over network. But because I have to support two platforms (x64 and ARM32) this was a problem. The serialization (flatbuffers) needs an explicit type and cannot change between platforms between 32 and 64 bits.

Now with the current changes on the library I got compiler warnings like:

| src/raft_node.c: In function 'raft_node_get_next_idx':
| src/raft_node.c:60:31: error: cast increases required alignment of target type [-Werror=cast-align]
|      raft_node_private_t* me = (raft_node_private_t*)me_;

This is because the new raft_node_private_t is 64bit aligned but the void* only 32bit on ARM32.
At the end I went back to all 32bit types to have no alignement problems and fixed types for serialization.

Please consider all those experiences when defining the final fix for this whole problem or provide an explanation why long int was chosen. Because it differs in memory size on different platforms, see: en.cppreference.com/w/cpp/language/types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant