6: 2004-10-05 (火) 22:01:17 [4] | 現: 2024-01-08 (月) 12:58:51 ゲスト [5] | ||
---|---|---|---|
Line 87: | Line 87: | ||
/* "helloc4.cpp":helloをC++言語で記述した例 */ | /* "helloc4.cpp":helloをC++言語で記述した例 */ | ||
/* stack:4k malloc:1k */ | /* stack:4k malloc:1k */ | ||
+ | |||
/* このソースの説明が"helloc4.txt"に書かれています */ | /* このソースの説明が"helloc4.txt"に書かれています */ | ||
+ | |||
extern "C" { | extern "C" { | ||
#include <guigui00.h> | #include <guigui00.h> | ||
void OsaskMain(); | void OsaskMain(); | ||
} | } | ||
+ | |||
#define AUTO_MALLOC 0 | #define AUTO_MALLOC 0 | ||
+ | |||
class helloc4 { | class helloc4 { | ||
public: | public: | ||
Line 102: | Line 102: | ||
~helloc4(); | ~helloc4(); | ||
}; | }; | ||
+ | |||
helloc4::helloc4() { | helloc4::helloc4() { | ||
struct LIB_WINDOW *window; | struct LIB_WINDOW *window; | ||
struct LIB_TEXTBOX *wintitle, *textbox; | struct LIB_TEXTBOX *wintitle, *textbox; | ||
+ | |||
/* ライブラリの初期化(必ず最初にやらなければならない) */ | /* ライブラリの初期化(必ず最初にやらなければならない) */ | ||
lib_init(AUTO_MALLOC); | lib_init(AUTO_MALLOC); | ||
+ | |||
/* ウィンドウのオープン */ | /* ウィンドウのオープン */ | ||
window = lib_openwindow(AUTO_MALLOC, 0x0200, 136, 48); | window = lib_openwindow(AUTO_MALLOC, 0x0200, 136, 48); | ||
+ | |||
/* ウィンドウタイトル用のテキストボックスをオープン */ | /* ウィンドウタイトル用のテキストボックスをオープン */ | ||
wintitle = lib_opentextbox(0x1000, AUTO_MALLOC, 0, 7, 1, 0, 0, window, 0x00c0, 0); | wintitle = lib_opentextbox(0x1000, AUTO_MALLOC, 0, 7, 1, 0, 0, window, 0x00c0, 0); | ||
+ | |||
/* "hello, world"を表示するためのテキストボックスをオープン */ | /* "hello, world"を表示するためのテキストボックスをオープン */ | ||
textbox = lib_opentextbox(0x0000, AUTO_MALLOC, 0, 12, 1, 16, 16, window, 0x00c0, 0); | textbox = lib_opentextbox(0x0000, AUTO_MALLOC, 0, 12, 1, 16, 16, window, 0x00c0, 0); | ||
+ | |||
/* ウィンドウタイトルを表示 */ | /* ウィンドウタイトルを表示 */ | ||
lib_putstring_ASCII(0x0000, 0, 0, wintitle, 0, 0, "helloc4"); | lib_putstring_ASCII(0x0000, 0, 0, wintitle, 0, 0, "helloc4"); | ||
+ | |||
/* メッセージを表示 */ | /* メッセージを表示 */ | ||
lib_putstring_ASCII(0x0000, 0, 0, textbox, 0, 0, "hello, world"); | lib_putstring_ASCII(0x0000, 0, 0, textbox, 0, 0, "hello, world"); | ||
+ | |||
/* 終了 */ | /* 終了 */ | ||
lib_waitsignal(0x0001, 0, 0); | lib_waitsignal(0x0001, 0, 0); | ||
} | } | ||
+ | |||
helloc4::~helloc4(){} | helloc4::~helloc4(){} | ||
+ | |||
void OsaskMain() | void OsaskMain() | ||
{ | { | ||
Line 141: | Line 141: | ||
-ライブラリ出来ました。VCにパスを通し、CL = cl.exe -I$(INCPATH) -c としました。 -- ''uchan'' SIZE(10){2004-10-04 (月) 07:16:28} | -ライブラリ出来ました。VCにパスを通し、CL = cl.exe -I$(INCPATH) -c としました。 -- ''uchan'' SIZE(10){2004-10-04 (月) 07:16:28} | ||
-ものぐさな人に必要な処置を施したosa_dir2改をあげておきます。http://bayside.upper.jp/upload/osasksdk-20041005.lzh -- ''bayside'' SIZE(10){2004-10-05 (火) 22:01:17} | -ものぐさな人に必要な処置を施したosa_dir2改をあげておきます。http://bayside.upper.jp/upload/osasksdk-20041005.lzh -- ''bayside'' SIZE(10){2004-10-05 (火) 22:01:17} | ||
+ | -obj2bim3で"Warning : can't link ??2@YAPAXI@Z"が発生。どうもnewがリンクできていないらしい。 -- ''bayside'' SIZE(10){2004-10-06 (水) 15:17:52} | ||
+ | -つまりnew演算子用のランタイムがVCにあって、それが無いからリンクできないのでしょう。おそらくランタイムはOSに依存するので、VCのランタイムから持ってくるだけでは解決できないと思います。 -- [[K]] SIZE(10){2004-10-06 (水) 15:58:27} | ||
+ | -inline void* operator new(size_t n){ return malloc(n); } でたいていの環境でnewが使えるようになるはづ。 -- [[名無しさん]] SIZE(10){2004-10-06 (水) 17:28:47} | ||
#comment | #comment |
(This host) = http://osask.net