LNK2001何故かリンカエラーです……助けてください

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
アバター
結城
記事: 52
登録日時: 14年前
連絡を取る:

LNK2001何故かリンカエラーです……助けてください

#1

投稿記事 by 結城 » 14年前

こんばんは
ちゃんと定義したつもりなのです
なのですが、include文を少しいじくるとエラーがどばっと出てきたり
リンカエラーになります
(大量に出るエラーはたぶん関係ない未チェックの奴でしょうけど……むしろそうであることを願います)

コードは以下のものです
SAIS -Iris-.cpp[一部]

コード:

#define global_instance

#include "stdafx.h"
#include "SAIS -Iris-.h"
#include "global.h"

#define MAX_LOADSTRING 100
#define ID_EDIT 100

// グローバル変数:
HINSTANCE hInst;								// 現在のインターフェイス
TCHAR szTitle[MAX_LOADSTRING];					// タイトル バーのテキスト
TCHAR szWindowClass[MAX_LOADSTRING];			// メイン ウィンドウ クラス名
HWND hEdit; 

global.h

コード:

#define vt(_n) #_n

#define NUM_DRAWNUM 256
/*Define DrawSwitch of Drawprocess*/
#define _DS _int16
#define _DSFA_XYONLY 0x01
#define _DSFA_RECTMODE 0x02
#define _DSFA_AUTODIVISION 0x03
#define _DSFB_LPCWSTRTYPE 0x10
#define _DSFB_LPTSTRTYPE 0x20

#ifdef global_instance
#define global
#else
#define global extern
#endif

typedef struct{
	LPCWSTR lpchtext;
	LPCWSTR facename;
	int size;
	int x;
	int y;
	int w;
	int h;
	int flag;
	COLORREF bkcolor;

}dp_ts_t;/*for loop process of PrintMessage()*/
global dp_ts_t dp_ts; 

#ifdef global_intstance
global dp_ts_t *draw_process_text = new dp_ts[NUM_DRAWNUM];
#else
global dp_ts_t *draw_process_text;
#endif

template <class T>
int _DSF_SEPARATER(HWND hwnd,T x,T y)
{
	if((
		x == _DSFA_XYONLY ||
		x == _DSFA_RECTMODE ||
		x == _DSFA_AUTODIVISION) && (
		y == _DSFB_LPCWSTRTYPE ||
		y == _DSFB_LPTSTRTYPE))
	{
		return x+y;
	}else if((
		y == _DSFA_XYONLY ||
		y == _DSFA_RECTMODE ||
		y == _DSFA_AUTODIVISION) && (
		x == _DSFB_LPCWSTRTYPE ||
		x == _DSFB_LPTSTRTYPE))
	{
		return x+y;
	}else if((
		x == _DSFA_XYONLY ||
		x == _DSFA_RECTMODE ||
		x == _DSFA_AUTODIVISION) && (
		y == _DSFA_XYONLY || 
		y == _DSFA_RECTMODE ||
		y == _DSFA_AUTODIVISION) || (
		x == _DSFB_LPCWSTRTYPE ||
		x == _DSFB_LPTSTRTYPE) && (
		y == _DSFB_LPCWSTRTYPE ||
		y == _DSFB_LPTSTRTYPE))
	{
		MessageBox(
			hwnd,
			L"ERROR",
			L"The same mode repeats in an argument, and it is appointed",
			MB_APPLMODAL);
		return -1;
	}
}

global int now_state;

#include "defunc.h"
問題の外部
InterfaceA.cpp一部

コード:

#include "stdafx.h"
#include "scope of capacity.h"

void initialize()
{
	now_state = 0x00;
	_DEF_PLUSCONTENTS(L"SAIS -Iris- starts with a test mode.\nAll functions are limited now",L"MS UI Gothic",12,0,0,0,0,RGB(0,0,0));
}
問題の外部
PlusFunction.cpp一部

コード:

int _DEF_PLUSCONTENTS(
					   LPCWSTR lpchText,
					   LPCWSTR facename,
					   int size,
					   int x,
					   int y,
					   int w,
					   int h,
					   COLORREF bkcolor)
{
	for(int i=0;i<NUM_DRAWNUM;i++)
	{
		if(draw_process_text[i].flag == 0)
		{
			draw_process_text[i].lpchtext = lpchText;
			draw_process_text[i].facename = facename;
			draw_process_text[i].size = size;
			draw_process_text[i].x = x;
			draw_process_text[i].y = y;
			draw_process_text[i].w = w;
			draw_process_text[i].h = h;
			draw_process_text[i].bkcolor = bkcolor;
			draw_process_text[i].flag = true;
			return i;
		}
	}
}
べたっと長いの張り付けましたがどうかお願いします
[hr]
すみません書き忘れてました
エラーメッセージです

エラー 6 error LNK2001: 外部シンボル ""struct dp_ts_t * draw_process_text" (?draw_process_text@@3PAUdp_ts_t@@A)" は未解決です。 Plusfunction.obj
エラー 7 error LNK2001: 外部シンボル ""struct dp_ts_t * draw_process_text" (?draw_process_text@@3PAUdp_ts_t@@A)" は未解決です。 SAIS -Iris-.obj
エラー 8 error LNK2001: 外部シンボル ""int now_state" (?now_state@@3HA)" は未解決です。 InterfaceA.obj
エラー 9 fatal error LNK1120: 外部参照 2 が未解決です。 U:\SAIS -Iris-\Debug\SAIS -Iris-.exe 1
ANGE;ART

Poco
記事: 161
登録日時: 14年前

Re: LNK2001何故かリンカエラーです……助けてください

#2

投稿記事 by Poco » 14年前

情報不足です。
エラーが再現できる最低限のソース(この場合全部)を載せてください。

アバター
結城
記事: 52
登録日時: 14年前
連絡を取る:

Re: LNK2001何故かリンカエラーです……助けてください

#3

投稿記事 by 結城 » 14年前

あ、すみません
リンカエラーの方は解決してしまいました

お騒がせしました
ANGE;ART

アバター
結城
記事: 52
登録日時: 14年前
連絡を取る:

Re: LNK2001何故かリンカエラーです……助けてください

#4

投稿記事 by 結城 » 14年前

解決方法を載せておきます

stdafx.hに#include "global.h"を追加したのみです
結果はリンクされてエラーも消えました
ANGE;ART

閉鎖

“C言語何でも質問掲示板” へ戻る