루미앗

proc to_uint32(self: seq[uint8]): uint32 =
  if self.len() != 4:
    return 0
  result = (cast[uint32](self[3]) shl 0) or
          (cast[uint32](self[2]) shl 8) or
          (cast[uint32](self[1]) shl 16) or
          (cast[uint32](self[0]) shl 24)

proc to_uint8_seq(self: uint32): seq[uint8] =
  result = @[]
  result.add(cast[uint8](self shr 0))
  result.add(cast[uint8](self shr 8))
  result.add(cast[uint8](self shr 16))
  result.add(cast[uint8](self shr 24))

when isMainModule:
  let sample = @[0x00'u8, 0x00, 0x00, 0x10]
  echo sample.to_uint32()                    # 16
  echo sample.to_uint32().to_uint8_seq()    # @[0, 0, 0, 16]

'공부 > Nim' 카테고리의 다른 글

seq[uint8] => uint32  (0) 2019.05.25

Comment +0

다음 참조: http://wapel.de/?p=603

위에 나온 deps 모두 깔고 다음 명령어 실행

sudo apt-get install libc6-armhf-cross libc6-dev-armhf-cross
sudo ln -s /lib/arm-linux-gnueabihf/libpthead-2.14.so /usr/lib/arm-linux-gnueabihf/libpthread.so.0
sudo rm -rf /usr/lib/chromium-browser/libs

여기 에서 raspberry-gcc6.3.0-r4.exe를 설치하고 TOOLS/UpdateSysroot.bat를 실행한다.
다음 경로를 붙여넣는다.

/lib
/usr/include
/usr/lib
/usr/local/include
/usr/local/lib
/opt

이제 하단 체크박스를 클릭하고 sync 한다.

./configure -release -opengl es2 -device linux-rasp-pi3-g++ -platform win32-g++ -device-option CROSS_COMPILE="/c/SysGCC/raspberry/bin/arm-linux-gnueabihf-" -sysroot /c/SysGCC/raspberry/arm-linux-gnueabihf/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix /root/qt5pi -hostprefix /root/qt5 -no-use-gold-linker -v -no-gbm -nomake examples -nomake tests -qt-freetype -qt-harfbuzz -skip qtscript -no-xcb

2019.05.04 deps 수정

Comment +0