microsoft / microsoft/vscode-cpptools

Leverage compiler system defines to determine types and sizes for IntelliSense

オープン
#7,355 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Feature Request internal Language Service
主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

説明

Various type and sizes are essentially hard-coded per IntelliSense mode. Some are passed in based on a static file (such as __SIZE_TYPE__ and __PTRDIFF_TYPE in linux.gcc.x64.json). Some are hard-coded in the IntelliSense parser, based on the compiler and architecture (IntelliSense mode).

gcc/clang compilers will output types and sizes when queried, such as:

c:\msys64\mingw64\bin>gcc.exe -x c++ -E -dM nul | findstr /i SIZEOF
#define __SIZEOF_FLOAT80__ 16
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_DOUBLE__ 16
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_SIZE_T__ 8
#define __SIZEOF_WINT_T__ 2
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_PTRDIFF_T__ 8
#define __SIZEOF_INT__ 4
#define __SIZEOF_FLOAT128__ 16
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_INT128__ 16
#define __SIZEOF_WCHAR_T__ 2
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8

c:\msys64\mingw64\bin>gcc.exe -x c++ -E -dM nul | findstr /i long
#define __UINTMAX_TYPE__ long long unsigned int
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_DOUBLE__ 16
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
#define __LONG_LONG_WIDTH__ 64
#define __INT_FAST64_TYPE__ long long int
#define __SIZE_TYPE__ long long unsigned int
#define __UINT_LEAST64_TYPE__ long long unsigned int
#define __LONG_MAX__ 0x7fffffffL
#define __INT_LEAST64_TYPE__ long long int
#define __GCC_ATOMIC_LONG_LOCK_FREE 2
#define __INTPTR_TYPE__ long long int
#define __UINT_FAST64_TYPE__ long long unsigned int
#define __INT64_TYPE__ long long int
#define __UINT64_TYPE__ long long unsigned int
#define __LONG_WIDTH__ 32
#define __INTMAX_TYPE__ long long int
#define __PTRDIFF_TYPE__ long long int
#define __UINTPTR_TYPE__ long long unsigned int
#define __SIZEOF_LONG_LONG__ 8
#define __GCC_ATOMIC_LLONG_LOCK_FREE 2

It's possible that different versions or flavors of the same compiler will output different values for these, even for the same architecture.

For example, both MinGW x64 and cygwin x64 are associated with the windows-gcc-x64 IntelliSense mode, but use different sizes for long.

D:\cygwin64\bin>gcc.exe -x c++ -E -dM /dev/null | findstr /i x86
#define __x86_64 1

D:\cygwin64\bin>gcc.exe -x c++ -E -dM /dev/null | findstr /i SIZEOF_LONG
#define __SIZEOF_LONG__ 8


c:\msys64\mingw64\bin>gcc.exe -x c++ -E -dM nul | findstr /i x86
#define __x86_64 1

c:\msys64\mingw64\bin>gcc.exe -x c++ -E -dM nul | findstr /i SIZEOF_LONG
#define __SIZEOF_LONG__ 4

Some gcc ports to Windows follow Windows conventions for types and sizes, and some use Linux conventions.

To improve compatibility between different versions and flavors of gcc compilers, we could use the queried system defines from the compiler to correct types and sizes.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リポジトリのファイルもテストも指定されていません。まず、IntelliSense パーサーでの型とサイズのハードコードされた処理、およびコンパイラー問い合わせの経路を、示されている gcc -E -dM コマンドを参照動作として追跡してください。異なる GCC port とバージョン間で、コンパイラーが報告した define によって型とサイズを修正できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
compilers, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。