This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

__DATE__ and RTX51 Tiny give link errors

This declaration

const char code* const gBuildDate = __DATE__;

gives lots of link errors when I use RTX51 Tiny but is fine without RTX.
(My program uses conditional compilation to build either a RTX or non-RTX version)
Any ideas?

  • This always works for me:

    // In each module
    static const char s_moduleInfo[] = __FILE__ " modified " __DATE__ " at " __TIME__;
    
    // Or in one module that is set to "always build".
    const char g_projInfo[] = "Project modified " __DATE__ " at " __TIME__;
    - Mark

  • What link errors?

    const char code* const gBuildDate = __DATE__;
    Don't you have too many 'const' there?

  • const char code* const gBuildDate = __DATE__;
    Don't you have too many 'const' there?

    I don't think so, it says, "gBuildDate is a const pointer to const char". Thus you cannot modify either gBuildDate or what it points to. You have to remember that 'code' is not ISO C and yet Keil still supports ISO C as much as it can.

    Without the code keyword it is more obvious:

    const char *pVar;        // pVar can be modfied but not what it points to.
    char * const pVar;       // pVar cannot be modified but what it points to can.
    const char * const pVar; // Neither pVar nor what it points to can be modified.
    - Mark

  • Ok Ive realised whats wrong - I was running out of DATA space.
    If I change the declaration to this

    const char code* code gBuildDate = __DATE__;

    its OK.
    I expected since the pointer was 'const' it would automatically go into code space but apparently not, you have to use 'code'.