Search code examples
cnxp-microcontroller

undefined reference to 'strftime with Kinetis KL25Z Board and Codewarrior IDE


I'm trying to convert a tm struct to a string using strftime() in a Kinetis KL25Z using codewarrior ide.

When calling strftime i get an error saying "undefined reference to 'strftime'". Test code used below:

#include "derivative.h" /* include peripheral declarations */

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

struct tm dateinfo;
struct tm *dateinfoPointer=&dateinfo;

int main(void)
{
    int counter = 0;

    char buffer[8];
    strftime(buffer,sizeof(buffer),"%H:%M:%S",dateinfoPointer);


    for(;;) {      
        counter++;
    }

    return 0;
}

What I'm missing?


Solution

  • I would be surprised if this function is implemented for your Cortex M0 uC. Usually time.h functions are not implemented or the functions are on;y the stubs. Programming such a small micros you need to forget your Windows/Linux programming habits.

    So how to deal with time? Write it yourself :)