複数のインクルードなしですべてのフィールドにアクセスする方法を教えてください。
あなたはありません。これは、外部コードへのアクセスを得るためのものです。
しかし、いくつかのコンパイラ、たとえば。 man gcc
から
-include <filename>
Adds an implicit #include into the predefines buffer which is read
before the source file is preprocessed.
:man clang
から
:クランとGCC、暗黙の#include
秒を挿入するために使用することができますフラグをサポートし、この方法はまだ含めるしようとしていること
-include file
Process file as if "#include "file"" appeared as the first line of the
primary source file. However, the first directory searched for file
is the preprocessor's working directory instead of the directory
containing the main source file. If not found there, it is searched
for in the remainder of the "#include "..."" search chain as normal.
If multiple -include options are given, the files are included in the
order they appear on the command line.
注意をこれらのファイルは通常の方法でやるほうがよいでしょう。
あなたの質問には、混乱があります。あなたがここで言ったのとは反対に、**は '#include'を使用し、コンパイル時に-Iフラグを使用する必要があります。 – Dovahkiin
構造体のフィールドにアクセスするには、構造体の定義にアクセスする必要があります。構造体の定義には、#構造体を含むヘッダが含まれている必要があります。 –
はい、わかりました。しかし、私はアクセスが必要な構造がたくさんある場合、ヘッダーを含める必要性を回避する方法はありますか? – marc