AntelopeIO / abieos

Other
2 stars 12 forks source link

avoid using multi-character to improve portability and clean up warnings in doing so #8

Closed linh2931 closed 2 years ago

linh2931 commented 2 years ago

Multi-character is not defined by C++ standard and is implementation-defined: https://en.cppreference.com/w/cpp/language/character_literal.

Change to calculate the symbol value deterministically and at compile time in the same way as previous multi-character implementation. The newly added function multichars_to_uint32 was tested in both gcc and clang.

Fix the following warnings:

/home/lh/work/leap-main/tests/abieos/src/template_test.cpp:230:25: warning: multi-  character character constant [-Wmultichar]
  230 |    test(symbol{unsigned('ZYX\x08')}, abi, new_abi);
      |                         ^~~~~~~~~
/home/lh/work/leap-main/tests/abieos/src/template_test.cpp:231:30: warning: multi-  character character constant [-Wmultichar]
  231 |    test(symbol_code{unsigned('ZYXW')}, abi, new_abi);
      |                              ^~~~~~
/home/lh/work/leap-main/tests/abieos/src/template_test.cpp:232:25: warning: multi-  character character constant [-Wmultichar]
  232 |    test(asset{5, symbol{'ZYX\x08'}}, abi, new_abi);
      |                         ^~~~~~~~~
linh2931 commented 2 years ago

Thanks for your comment! That's my thought too, as the function is only intended for the 3 test cases immediately follows. I did not want to clutter the code.