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

Sub String in Pre-Processor?

Does anyone know how to get the pre-processor to spit out a substring? In this case, I want to include only the year from the __DATE__ macro.
Something like:

#define YEAR=substr(8,4,__DATE__)
const char code ROMSTRING={"COPYRIGHT " YEAR "by such and such company. Compiled on " __DATE__};

where the #define is something the pre-processor can handle.

Thanks

Parents
  • As it stands now, we are abusing the bug in the compiler where the terminating null can be supressed in a definition:

    const code char s1[]="ABCD" // this is 5 chars long (with NULL)
    const code char s2[4]="ABCD" // this 4 chars long (NO NULL)
    


    That is not a bug. That is expected behaviour - a special case for initializing character arrays. You can do it with all (non-broken) C compilers.

Reply
  • As it stands now, we are abusing the bug in the compiler where the terminating null can be supressed in a definition:

    const code char s1[]="ABCD" // this is 5 chars long (with NULL)
    const code char s2[4]="ABCD" // this 4 chars long (NO NULL)
    


    That is not a bug. That is expected behaviour - a special case for initializing character arrays. You can do it with all (non-broken) C compilers.

Children