0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ソースコード内でのTeensyの判別

Last updated at Posted at 2021-03-23

同じソースをTeensyと他の一般的なOS用とで共用する時に、Teensyだけで定義したい何かとかその逆があると思うんだけど、その時にはこれを使えば良いっぽい。

hoge.cpp
#if defined(TEENSYDUINO)
()
#endif

ボクは何か変数をFLASHに置きたい時にこんな風にしてる。PROGMEMはTeensy(というかArduino)で変数をFLASHに置く指定。

hoge.cpp
#if defined(TEENSYDUINO)
#include <avr/pgmspace.h>
#else
#define PROGMEM const
#endif

PROGMEM unsigned int const_var_temp = 100;

なぜかTeensyでビルドする時にPROGMEMとconstを同時に使うとエラーになるので、上記のようにしている。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?