project-mahiwa / mahiwa-backend

mahiwaのバックエンド
GNU Lesser General Public License v2.1
0 stars 0 forks source link

[🐛Bug]: constrainの値がおかしい #94

Open usuyuki opened 9 months ago

usuyuki commented 9 months ago

🐛 概要

    serial.Print("constrain(100,0,10): ")
    serial.PrintInt(arduino.Constrain(100, 0, 10))
    serial.Println("")

の値が

constrain(100,0,10): 21

になる。

原因

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

マクロで展開する感じなので、コンパイル後に動的にくる値に対応できない?

備考

usuyuki commented 9 months ago

rust未検証