static __tb_inline__ tb_bool_t xm_version_check(tb_hize_t build) { // the version oly for link the static vtag string tb_version_t const* version = tb_version(); tb_used(version); // ok if ((build / 100) == (XM_VERSION_BUILD / 100)) { tb_trace_d("version: %s", XM_VERSION_STRING); return tb_true; } else { tb_trace_w("version: %s != %llu", XM_VERSION_STRING, build); } // no return tb_false; }
static __tb_inline__ tb_bool_t tb_version_check(tb_hize_t build) { #ifdef TB_CONFIG_INFO_HAVE_VERSION // the version oly for link the static vtag string tb_version_t const* version = tb_version(); tb_used(version); #endif // ok if ((build / 100) == (TB_VERSION_BUILD / 100)) { tb_trace_d("version: %s", TB_VERSION_STRING); return tb_true; } else { tb_trace_w("version: %s != %llu", TB_VERSION_STRING, build); } // no return tb_false; }
/* ////////////////////////////////////////////////////////////////////////////////////// * main */ tb_int_t tb_demo_utils_option_main(tb_int_t argc, tb_char_t** argv) { // init option tb_option_ref_t option = tb_option_init("option", "the option command test demo", g_options); if (option) { // done option if (tb_option_done(option, argc - 1, &argv[1])) { // done dump tb_option_dump(option); // done help if (tb_option_find(option, "help")) tb_option_help(option); // done version else if (tb_option_find(option, "version")) { tb_version_t const* version = tb_version(); if (version) tb_trace_i("version: tbox-v%u.%u.%u.%llu", version->major, version->minor, version->alter, version->build); } else { // done integer if (tb_option_find(option, "i")) tb_trace_i("integer: %lld", tb_option_item_sint64(option, "i")); // done string if (tb_option_find(option, "s")) tb_trace_i("string: %s", tb_option_item_cstr(option, "s")); #ifdef TB_CONFIG_TYPE_HAVE_FLOAT // done float if (tb_option_find(option, "f")) tb_trace_i("float: %f", tb_option_item_float(option, "f")); #endif // done boolean if (tb_option_find(option, "b")) tb_trace_i("boolean: %s", tb_option_item_bool(option, "b")? "y" : "n"); // done demo if (tb_option_find(option, "demo")) tb_trace_i("demo: %s", tb_option_item_cstr(option, "demo")); // done file0 if (tb_option_find(option, "file0")) tb_trace_i("file0: %s", tb_option_item_cstr(option, "file0")); // done file1 if (tb_option_find(option, "file1")) tb_trace_i("file1: %s", tb_option_item_cstr(option, "file1")); // done more tb_size_t more = 0; while (1) { tb_char_t name[64] = {0}; tb_snprintf(name, 63, "more%lu", more++); if (tb_option_find(option, name)) tb_trace_i("%s: %s", name, tb_option_item_cstr(option, name)); else break; } } } else tb_option_help(option); // exit option tb_option_exit(option); } return 0; }