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?

#include Windows.hしたときにinterfaceという変数名が使えない

Last updated at Posted at 2025-03-29

概要

MSVCの環境で変数名にinterfaceという命名をしたところ、以下のようなエラーが出た。

実際のコード:

int main() {
    int interface = 20;
    printf("%d", interface);
    return 0;
}

エラー:
image.png

結論

どうやら、MSVCの予約語にinterfaceが含まれておりその予約語を使用した命名や関数の定義を行うとエラーが出るらしい。

#include <Windows.h>をした時のものによる影響でした。 (2025/03/31)

(Visual Studioではわかりやすくハイライトされたが、ClionやVSCodeではハイライトされなくて分かりにくかったのでメモ)

0
0
2

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?