×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    208

    Thumbs up question about __FUNCTION__ and __FILE__

    i can use __FUNCTION__ and __FILE__to debug in vc,

    does carbide can use these?

    if can how to do?

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: question about __FUNCTION__ and __FILE__

    yes, the macro is defined in vc or carbide, gcce compiler, etc.

    use as normal macro. like

    Code:
    class CFuncTrace
    {
    public:
        CFuncTrace(const char* file, const char* func, int line)
        {
            iFile = (const TUint8*)file;
            iFunc = (const TUint8*)func;
            iLine = line;
            LOG_FMT( KFuncTraceEnterFormat, &iFile, &iFunc, iLine );
        }
        
        ~CFuncTrace()
        {
            LOG_FMT( KFuncTraceLeaveFormat, &iFile, &iFunc, iLine );
        }
    
    private:
        CFuncTrace(const CFuncTrace&);
        CFuncTrace& operator= (const CFuncTrace&);
        
    private:
        TBuf8<100>      iFile;
        TBuf8<100>      iFunc;
        int             iLine;
    };
    
    
    #define FUNC_TRACE(name)            CFuncTrace name(__FILE__, __FUNCTION__, __LINE__)
    #define FUNC_U_TRACE()              CFuncTrace _func_trace_(__FILE__, __FUNCTION__, __LINE__)
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    208

    Re: question about __FUNCTION__ and __FILE__

    thanks!

    i wrote const char* tc = __FILE__ ;
    and compiled error,prompt crosses initialization of `const char*tc'

    what should do?

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: question about __FUNCTION__ and __FILE__


  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: question about __FUNCTION__ and __FILE__

    Quote Originally Posted by ptclin_2007 View Post
    i wrote const char* tc = __FILE__ ;
    and compiled error,prompt crosses initialization of `const char*tc'
    Statement const char* tc = __FILE__; looks fine to me. I am wondering why its gives you a initialization error.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: question about __FUNCTION__ and __FILE__

    What is the exact error message you get? Where have you written that line?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×