`
lua
  • 浏览: 74801 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

Change Ugly code in our project

 
阅读更多

following code happens many times in our project:

 

                        xxxxxxx;


#if defined _ETHERNET
                        tmp1String = deviceKey.GetAddressAsString();
#else
                        tmp1String = deviceKey.GetNodeAsString();
#endif
                        yyyyyyy;

 

 

It should be changed like:

 

CString GetAddrString(DeviceKey& deviceKey)

{

        CString tmp1String;

#if defined _ETHERNET
                        tmp1String = deviceKey.GetAddressAsString();
#else
                        tmp1String = deviceKey.GetNodeAsString();
#endif

        return tmp1String;

}

 

then we could use the function like:

 

     xxxxxxx;

     tmp1String = GetAddrString(deviceKey);
     yyyyyyy;

 

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics