C++库研究笔记--用__attribute__((deprecated)) 管理过时代码

时间:2014-10-06 15:53:50   收藏:0   阅读:312

用__attribute__((deprecated)) 管理过时代码,同时保留兼容的接口

Linux下:

#define  DEPR_AFTER __attribute__((deprecated))
#define  DEPR_BEFOR 


class DEPR_BEFOR AAA
{
}DEPR_AFTER;

int main(int argc, char** argv)
{
    typedef float T;
    AAA aa;

    return 0;
}

g++ main.cpp -o main

main.cpp: In function ‘int main(int, char**)’:
main.cpp:16:9: warning: ‘AAA’ is deprecated (declared at main.cpp:9) [-Wdeprecated-declarations]


WINDOWS下:

对于VC,类似如OPENCV定义:

#if defined __GNUC__
    #define __CV_GPU_DEPR_BEFORE__
    #define __CV_GPU_DEPR_AFTER__ __attribute__ ((deprecated))
#elif defined(__MSVC__) //|| defined(__CUDACC__)
    #pragma deprecated(DevMem2D_)
    #define __CV_GPU_DEPR_BEFORE__ __declspec(deprecated)
    #define __CV_GPU_DEPR_AFTER__
#else
    #define __CV_GPU_DEPR_BEFORE__
    #define __CV_GPU_DEPR_AFTER__
#endif


原文:http://blog.csdn.net/mathgeophysics/article/details/39828427

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!