a4_0001
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* acl4のページ0001
-(by [[K]], 2026.01.23)
** (1)
#if (!defined(a_DbgLv))
#define a_DbgLv 2
#endif
#if (!defined(a_Version))
#define a_Version 1
#endif
#if (a_DbgLv < 2)
#define _argDef_
#define _argDef
#define _arg_
#define _arg
#else
#define _argDef_ const char *a_fil, int a_lin,
#define _argDef const char *a_fil, int a_lin
#define _arg_ __FILE__, __LINE__,
#define _arg __FILE__, __LINE__
#endif
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if (a_Version >= 1)
#define static_ a_static
#define class_ a_class
#define DbgLv a_DbgLv
#endif
#if (!defined(a_static))
#define a_static static
#endif
#define a_class(nam) typedef struct nam ## _ nam; str...
#if (a_Version >= 1)
#define errExit a_errExit
#endif
a_static void a_errExit(const char *f, ...)
{
va_list ap;
va_start(ap, f);
vfprintf(stderr, f, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}
** (2)
-命名規則:
--acl4ライブラリが提供するものについては、a_という接頭語...
--ただし a_Version というマクロ定数の値によっては、接頭語...
--staticのようにa_を外すと既存のC言語のキーワードとぶつか...
- _arg など:
--何のことかよくわからないと思いますが、[[a4_0002]]以降で...
-たくさんのinclude:
--標準関数がすぐに使えるように、たくさん include していま...
-a_staticは何のため?:
--acl4ではほぼすべての関数を static で宣言します。なぜな...
--これで「使わない関数が実行ファイルに入っている」という...
--でも分割コンパイルなどをするとかで、staticをつけないで...
-a_classは何のため?:
--structしてからtypedefするのが、面倒だなーって思ったので...
-a_errExit()は何をするの?:
--エラーメッセージをstderrに出力して、exit(1)します。まあ...
--改行もしてくれるので、エラーメッセージの末尾の改行を書...
** (3) 使い方
-acl4ライブラリは以下のようにして利用します。
-[1]まずa4_0001のプログラムを"acl4.c"として保存します。
-[2]次にacl4を使ったプログラムを書きます。
-[3]コンパイル時に、"acl4.c"のあるパスをインクルードパス...
-以下のコードでやってみます。"t0001a.c"とします。
#define a_Version 1
#include <acl4.c>
int main(int argc, const char **argv)
{
if (argc < 2) errExit("usage>t0001a file-path");
FILE *fp = fopen(argv[1], "rt");
if (fp == NULL) errExit("fopen error: %s", argv[1]);
for (;;) {
int c = fgetc(fp);
if (c == EOF) break;
putchar(c);
}
fclose(fp);
return 0;
}
** (4) Q&A
-[Q:00]なぜ.hファイルではなく.cファイルなのですか?
--[A:00].hファイルにするのは分割コンパイルをする場合だと...
--またacl4ライブラリはマクロ定数によってコード内容が大き...
--コンパイラの負担は増えますが、最近のコンパイラは非常に...
-[Q:01]acl4ライブラリについて感想や意見を言いたいのですが...
--[A:01]「[[osdev-jp>https://osdev.jp/]] / Discord / k-ta...
** (99) 更新履歴
-2026.01.23(金) 初版。
終了行:
* acl4のページ0001
-(by [[K]], 2026.01.23)
** (1)
#if (!defined(a_DbgLv))
#define a_DbgLv 2
#endif
#if (!defined(a_Version))
#define a_Version 1
#endif
#if (a_DbgLv < 2)
#define _argDef_
#define _argDef
#define _arg_
#define _arg
#else
#define _argDef_ const char *a_fil, int a_lin,
#define _argDef const char *a_fil, int a_lin
#define _arg_ __FILE__, __LINE__,
#define _arg __FILE__, __LINE__
#endif
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if (a_Version >= 1)
#define static_ a_static
#define class_ a_class
#define DbgLv a_DbgLv
#endif
#if (!defined(a_static))
#define a_static static
#endif
#define a_class(nam) typedef struct nam ## _ nam; str...
#if (a_Version >= 1)
#define errExit a_errExit
#endif
a_static void a_errExit(const char *f, ...)
{
va_list ap;
va_start(ap, f);
vfprintf(stderr, f, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}
** (2)
-命名規則:
--acl4ライブラリが提供するものについては、a_という接頭語...
--ただし a_Version というマクロ定数の値によっては、接頭語...
--staticのようにa_を外すと既存のC言語のキーワードとぶつか...
- _arg など:
--何のことかよくわからないと思いますが、[[a4_0002]]以降で...
-たくさんのinclude:
--標準関数がすぐに使えるように、たくさん include していま...
-a_staticは何のため?:
--acl4ではほぼすべての関数を static で宣言します。なぜな...
--これで「使わない関数が実行ファイルに入っている」という...
--でも分割コンパイルなどをするとかで、staticをつけないで...
-a_classは何のため?:
--structしてからtypedefするのが、面倒だなーって思ったので...
-a_errExit()は何をするの?:
--エラーメッセージをstderrに出力して、exit(1)します。まあ...
--改行もしてくれるので、エラーメッセージの末尾の改行を書...
** (3) 使い方
-acl4ライブラリは以下のようにして利用します。
-[1]まずa4_0001のプログラムを"acl4.c"として保存します。
-[2]次にacl4を使ったプログラムを書きます。
-[3]コンパイル時に、"acl4.c"のあるパスをインクルードパス...
-以下のコードでやってみます。"t0001a.c"とします。
#define a_Version 1
#include <acl4.c>
int main(int argc, const char **argv)
{
if (argc < 2) errExit("usage>t0001a file-path");
FILE *fp = fopen(argv[1], "rt");
if (fp == NULL) errExit("fopen error: %s", argv[1]);
for (;;) {
int c = fgetc(fp);
if (c == EOF) break;
putchar(c);
}
fclose(fp);
return 0;
}
** (4) Q&A
-[Q:00]なぜ.hファイルではなく.cファイルなのですか?
--[A:00].hファイルにするのは分割コンパイルをする場合だと...
--またacl4ライブラリはマクロ定数によってコード内容が大き...
--コンパイラの負担は増えますが、最近のコンパイラは非常に...
-[Q:01]acl4ライブラリについて感想や意見を言いたいのですが...
--[A:01]「[[osdev-jp>https://osdev.jp/]] / Discord / k-ta...
** (99) 更新履歴
-2026.01.23(金) 初版。
ページ名: