Document of c-modernization-kit (override-sample) 1.0.0
Loading...
Searching...
No Matches
override-sample.c
Go to the documentation of this file.
1
15
16#include <libbase.h>
17#include <console-util.h>
18#include <stdio.h>
19#ifdef _WIN32
20 #include <windows.h>
21#endif /* _WIN32 */
22
29int main(void)
30{
31 console_init();
32
33 int result;
34 int rtc;
35 char configpath[4096];
36
37#ifndef _WIN32
38 snprintf(configpath, sizeof(configpath), "/tmp/libbase_extdef.txt");
39#else /* _WIN32 */
40 {
41 wchar_t tmpw[MAX_PATH] = L"";
42 DWORD n = GetTempPathW((DWORD)(sizeof(tmpw) / sizeof(tmpw[0])), tmpw);
43 configpath[0] = '\0';
44 if (n > 0 && n < (DWORD)(sizeof(tmpw) / sizeof(tmpw[0])))
45 {
46 char tmpu8[MAX_PATH * 4] = {0};
47 int m = WideCharToMultiByte(CP_UTF8, 0, tmpw, -1, tmpu8, (int)sizeof(tmpu8), NULL, NULL);
48 if (m > 0)
49 snprintf(configpath, sizeof(configpath), "%slibbase_extdef.txt", tmpu8);
50 }
51 }
52#endif /* _WIN32 */
53
54 printf("configpath: %s\n", configpath);
55 printf("Processing will be extended if defines.\n");
56 printf(" e.g. echo \"sample_func liboverride override_func\" > \"%s\"\n", configpath);
57#ifndef _WIN32
58 printf(" rm \"%s\"\n\n", configpath);
59#else /* _WIN32 */
60 printf(" del \"%s\"\n\n", configpath);
61#endif /* _WIN32 */
62
63 printf("--- funcman info ---\n");
65 printf("rtc: %d\n\n", rtc);
66
67 rtc = sample_func(1, 2, &result);
68 console_output("rtc: %d\n", rtc);
69 if (rtc != 0)
70 {
71 fprintf(stderr, "func failed (sample_func(1, 2, &result))\n");
72 }
73 else
74 {
75 printf("result: %d\n", result);
76 }
77
78 console_dispose();
79 return 0;
80}
ベースライブラリ (動的リンク用) のヘッダーファイル。
BASE_EXPORT void BASE_API console_output(const char *format,...)
printf と同じ書式でコンソールに出力します。
BASE_EXPORT int BASE_API sample_func(const int a, const int b, int *result)
計算処理を行います。
Definition sample_func.c:20
BASE_EXPORT int BASE_API funcman_info_libbase(void)
libbase が管理する funcman_object ポインタ配列の内容を標準出力に表示します。
int main(void)
メインエントリポイント。