Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C で動的ライブラリを作成しました。このライブラリは のようなグローバル変数を使用しますstatic int a=1。今、私は自分のアプリでこのライブラリを使用しています。コンパイル時に、コンパイラは「a への未定義参照」というエラーを生成します。
static int a=1
これは何が原因でしょうか?
staticグローバル変数の場合、その変数はそのコンパイル単位でのみ使用可能になります。つまり、グローバルstatic int a;はライブラリの外では見えません。
static
static int a;
staticライブラリ ユーザーがアクセスできるようにする場合は、 をドロップします。