王朝网络
分享
 
 
 

ace 学习手记 20050829

王朝other·作者佚名  2006-01-10
宽屏版  字体: |||超大  

编译vc下:

解开压缩包以后 创建一个config.h 的文件

#define ACE_HAS_STANDARD_CPP_LIBRARY 1

#include "ace/config-win32.h"

打开工程文件就可以编译库了。

编译工程 需要注意的是 路径设置 一般我会在环境变量 path 和 include 设置相应参数

然后设置为多线程编译 可惜了 我不能用editplus 编译了 要用vc 参数不会

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

我决定从example 开始看代码:

// test_log_msg.cpp,v 4.20 2003/11/10 01:48:03 dhinton Exp

// ============================================================================

//

// = LIBRARY

// examples/Log_Msg

//

// = FILENAME

// test_log_msg.cpp

//

// = DESCRIPTION

// This program tests the Log_Msg abstraction and demontrates

// several use cases.

//

// = AUTHOR

// Douglas Schmidt <schmidt@cs.wustl.edu>

//

// ============================================================================

#include "ace/OS_main.h"

// FUZZ: disable check_for_streams_include

#include "ace/streams.h"

#include "ace/Log_Msg.h"

#include "ace/OS_NS_unistd.h"

#include "ace/OS_NS_stdlib.h"

ACE_RCSID(Log_Msg, test_log_msg, "test_log_msg.cpp,v 4.20 2003/11/10 01:48:03 dhinton Exp")

static void

cleanup (void)

{

ACE_DEBUG ((LM_INFO,

"leaving (%P)!\n"));

}

static void

cause_error (void)

{

errno = EWOULDBLOCK;

ACE_ERROR ((LM_DEBUG,

"would block\n"));

}

int

ACE_TMAIN (int argc, ACE_TCHAR *argv[])

{

// Note that the default behavior is to log to STDERR...

int counter = 1 ;

if (argc > 1)

{

if (ACE_LOG_MSG->open (argv[0],

ACE_Log_Msg::OSTREAM) == -1)

ACE_ERROR ((LM_ERROR,

"cannot open logger!!!\n"));

cause_error ();

// Check to see what happened.

if (ACE_LOG_MSG->op_status () == -1

&& ACE_LOG_MSG->errnum () == EWOULDBLOCK)

ACE_DEBUG ((LM_DEBUG,

"op_status and errnum work!\n"));

else

ACE_ERROR ((LM_ERROR,

"op_status and errnum failed!\n"));

}

else

{

if (ACE_LOG_MSG->open (argv[0]) == -1)

ACE_ERROR ((LM_ERROR,

"cannot open logger!!!\n"));

cause_error ();

// Check to see what happened.

if (ACE_LOG_MSG->op_status () == -1

&& ACE_LOG_MSG->errnum () == EWOULDBLOCK)

ACE_DEBUG ((LM_DEBUG,

"op_status and errnum work!\n"));

else

ACE_ERROR ((LM_ERROR,

"op_status and errnum failed!\n"));

// Exercise many different combinations of STDERR and OSTREAM.

ACE_DEBUG ((LM_INFO,

"%10f, %*s%s = %d\n",

3.1416 * counter++,

8,

"",

"hello",

10000));

ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);

ACE_LOG_MSG->msg_ostream (&cout);

ACE_DEBUG ((LM_INFO,

"%10f, %*s%s = %d\n",

3.1416 * counter,

8,

"",

"world",

10000 * counter++));

ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR);

ACE_DEBUG ((LM_INFO,

"%10f, %*s%s = %d\n",

3.1416 * counter,

8,

"",

"world",

10000 * counter++));

ACE_LOG_MSG->msg_ostream (0);

ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);

ACE_DEBUG ((LM_INFO,

"%10f, %*s%s = %d\n",

3.1416 * counter,

8,

"",

"world",

10000 * counter++));

ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM);

ACE_LOG_MSG->msg_ostream (&cerr);

ACE_DEBUG ((LM_INFO,

"%10f, %*s%s = %d\n",

3.1416 * counter,

8,

"",

"world",

10000 * counter++));

static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};

// Print out the binary bytes of the array in hex form.

ACE_LOG_MSG->log_hexdump (LM_DEBUG,

(char *) array,

sizeof array);

// Disable the LM_DEBUG and LM_INFO messages at the process level.

u_long priority_mask =

ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS);

ACE_CLR_BITS (priority_mask,

LM_DEBUG | LM_INFO);

ACE_LOG_MSG->priority_mask (priority_mask,

ACE_Log_Msg::PROCESS);

ACE_DEBUG ((LM_INFO,

"This LM_INFO message should not print!\n"));

ACE_DEBUG ((LM_DEBUG,

"This LM_DEBUG message should not print!\n"));

ACE_SET_BITS (priority_mask,

LM_INFO);

ACE_LOG_MSG->priority_mask (priority_mask,

ACE_Log_Msg::PROCESS);

ACE_DEBUG ((LM_INFO,

"This LM_INFO message should print!\n"));

ACE_DEBUG ((LM_DEBUG,

"This LM_DEBUG message should not print!\n"));

ACE_CLR_BITS (priority_mask, LM_INFO);

ACE_LOG_MSG->priority_mask (priority_mask,

ACE_Log_Msg::PROCESS);

ACE_DEBUG ((LM_INFO,

"This LM_INFO message should not print!\n"));

ACE_DEBUG ((LM_DEBUG,

"This LM_DEBUG message should not print!\n"));

char badname[] = "badname";

char *l_argv[2];

l_argv[0] = badname;

l_argv[1] = 0;

if (ACE_OS::execv (badname,

l_argv) == -1)

{

ACE_ERROR ((LM_ERROR,

"%n: (%x), %p%r\n",

10000,

badname,

cleanup));

ACE_OS::_exit ();

}

}

return 0;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有