RTT源码分析之main函数改写测试-1

 

/**
 * @file main.h
 * The prototype of the application's ORO_main
 *
 */

#include "startstop.h"
#include "../Logger.hpp"

/**
 * Forward declare this wrapper around the user code.
 * @see ORO_main
 */
int ORO_main_impl(int,char**);

/**
 * Declare the function 'int ORO_main(int argc, char **argv)' instead
 * of 'int main(int argc, char **argv)' such that the Real-Time
 * Toolkit can setup the OS environment, prior to executing user
 * code. Using ORO_main is optional, but in some RTOS'es, you'll be
 * required to call __os_init() and __os_exit() instead when not using
 * ORO_main.
 *
 * @see __os_init(), __os_exit()
 */
#define ORO_main                                                \
    main( int argc, char **argv) {                              \
        int res = -1;                                           \
        std::string location(argv[0]); location += "::main()";  \
        __os_init(argc, argv); {                                \
            RTT::Logger::In in(location.c_str());               \
            if ( __os_checkException(argc,argv) ) {             \
                try {                                           \
                    res = ORO_main_impl(argc, argv);            \
                } catch( std::exception& arg )                  \
                {                                               \
                    __os_printException(argv[0], arg);          \
                } catch( ... )                                  \
                {                                               \
                    __os_printFailure(argv[0]);                 \
                }                                               \
            } else {                                            \
                res = ORO_main_impl(argc, argv);                \
            }                                                   \
        } __os_exit();                                          \
        return res;                                             \
    }                                                           \
int ORO_main_impl

2简化改写main入口测试 代码

#include <stdio.h>

int ORO_main_impl(int,char**);

/**
 * Declare the function 'int ORO_main(int argc, char **argv)' instead
 * of 'int main(int argc, char **argv)' such that the Real-Time
 * Toolkit can setup the OS environment, prior to executing user
 * code. Using ORO_main is optional, but in some RTOS'es, you'll be
 * required to call __os_init() and __os_exit() instead when not using
 * ORO_main.
 *
 * @see __os_init(), __os_exit()
 */
#define ORO_main                                                \
    main( int argc, char **argv) {                              \
        int res = -1;                                           \
        res = ORO_main_impl(argc, argv);                        \
        return res;                                              \
    }                                                           \
int ORO_main_impl


int ORO_main(int argc, char** argv)
{
    printf("Hello World!\n");
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值