まず第一に、私はこれが千回尋ねられることを知っています。しかし、私はいくつかを開いて、誰もがそれをコンパイル/リンクするのを忘れました。とにかく、ヘッダーとファイルを含む別のファイルにリンクリストを作成しました。これは正常に機能しますが、新しい関数を追加しようとしましたが、「関数」への未定義の参照があります。ソースは次のとおりです。
list.c
#include "list.h"
struct node
{
item_t x;
struct node *next;
};
struct node* root;
//Window hider extension
void ToggleVisibleList(HWND currentHwnd)
{
if (root == 0)
return;
struct node *conductor = root;
while (conductor != 0)
{
HWND hwnd = (HWND)conductor->x;
ShowWindow(hwnd, IsWindowVisible(hwnd) ? SW_HIDE : SW_SHOW);
conductor = conductor->next;
}
ShowWindow(currentHwnd, IsWindowVisible(currentHwnd) ? SW_HIDE : SW_SHOW);
}
//...Rest of the file
list.h
#ifndef LIST_H
#define LIST_H
#include <stdlib.h>
#include <windows.h>
//Window hider extension
void ToggleVisibleList(HWND currentHwnd);
//.. rest of the header
main.c
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#include "list.h"
HWND currentHwnd;
//..
HHOOK hookKeyboard;
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= 0)
{
if (wParam == WM_KEYDOWN)
{
KBDLLHOOKSTRUCT* hookStruct = (KBDLLHOOKSTRUCT*)lParam;
if (hookStruct->vkCode == 'Z' && GetAsyncKeyState(VK_LCONTROL))
{
ToggleVisibleList(currentHwnd);
}
}
}
CallNextHookEx(hookKeyboard, nCode, wParam, lParam);
}
//..Rest of file
Mingw(OS:Windows 8 64ビット)を使用してコンパイルします。
gcc -o hider.exe main.c list.c -mwindows
C:\Users\...\AppData\Local\Temp\cc6sCa17.o:main.c:(.text+0x4bc): undefined reference to `ToggleVisibleList'
collect2: ld gaf exit-status 1 terug
//Translation: ld return exit-status 1
編集:ファイルの順序を入れ替えてみました。
質問を複製しなかったといいのですが、最初に20の質問を試したので、複製しなかったと思います。(そしてグーグル。)よろしく
回答:コンピュータを再起動してコンパイルしました。