yohhoyの日記

技術的メモをしていきたい日記

#elifdefと#elifndef

プログラミング言語C/C++のそれぞれ次期バージョンC2x(C23)/C++2b(C++23)では、新しいプリプロセッサディレクティブ#elifdef#elifndefが追加される予定。*1

  • #ifdef identifier#if defined(identifier)と等価
  • #ifndef identifier#if !defined(identifier)と等価
  • #elifdef identifier#elif defined(identifier)と等価
  • #elifndef identifier#elif !defined(identifier)と等価

おまけ:本提案に対する反応の一つ。

"if I had a time machine, I’d blow #ifdef up and just make people used #if defined(...), it’s better and more flexible and represents the same functionality";

No Us Without You - elifdef and elifndef | The Pasture

関連URL

*1:2021年6月現在、次期C言語C2xには採択済み。次期C++言語C++2bへの追加はまだ提案段階。 2021年9月投票にてC++2b採択が決定した。