I'm not really that familiar with C so please bear with me...
I'm writing some simple code for a watchdog timer on an Atmel Tiny 85, developing in AtmelStudio. I want to access the clock() function of the time.h library:
#include <time.h>
.....
void main() {
  clock_t start = clock();
  ....
}
Unfortunately the compiler complains that clock is an undefined reference. Every code example I have looked up on the web seems to be doing what I am doing. Is there some fundamental thing I am missing? Thanks!
Here is the full code:
#define F_CPU 1000000UL // 1 MHz
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <time.h>
#include <stdio.h>
#include <avr/wdt.h>
#include <stdint.h>
#include <util/atomic.h>
#define LED_PORT PB1
#define RST0_PORT PINB3
#define RST1_PORT PINB4
#define HEARTBEAT PINB0
volatile int HEARTBEAT_RECEIVED;
#define CLOCKS_PER_SECOND 1000000;
const int TIMEOUT_PERIOD = 120; //reset raspberry pi after this many seconds
void set_output();
void set_input();
void set_interrupts();
void run_timer(clock_t start);
void restart_raspberry_pi();
int main(void)
{
    clock_t start;
    HEARTBEAT_RECEIVED = false;
    //Configure IO pins
    set_output();
    set_input();
    PORTB &= ~(1 << RST0_PORT); // Set pin low (common ground pin for pi reset)
    PORTB &= ~(1 << RST1_PORT); // Set pin low (initialize for no pi reset)
    //Configure and enable interrupts
    set_interrupts();
    while (1) {
        sei();
        start = clock();
        run_timer(start);
    }
    return (0);
}
void run_timer(clock_t start) {
    double time_elapsed;
    do {
        _delay_ms(1000);
        if (HEARTBEAT_RECEIVED) { //If heartbeat detected, reset timer.
            HEARTBEAT_RECEIVED = false;
            return;
        }
        time_elapsed = ( clock() - start ) / CLOCKS_PER_SECOND;
    } while (time_elapsed < TIMEOUT_PERIOD);
    restart_raspberry_pi(); //Timeout period has elapsed, reset the pi
}
ISR(PCINT0_vect) {
    //Indicate that a heartbeat has been received
    HEARTBEAT_RECEIVED = true;
}
void restart_raspberry_pi() {
    cli();
    PORTB |= (1 << RST1_PORT); // Set pin high (sets RUN high to reset)
    _delay_ms(500);
    PORTB &= ~(1 << RST1_PORT); // Set pin low (release reset control)
}
void set_output()
{
    //The DDxn bit in the DDRx Register selects the direction of this pin.
    //If DDxn is written logic one, Pxn is configured as an output pin.
    //If DDxn is written logic zero, Pxn is configured as an input pin.
    //PORTB = (0<<PB0) | (1<<PB3);
    DDRB = (1<<DDB5) | (1<<DDB4) | (1<<DDB3) | (1<<DDB2) | (1<<DDB1); // Set pins as output.
}
void set_input()
{
    DDRB |= (0<<DDB0); // set pin 0 as input. Added |=.
}
void set_interrupts()
{
    GIMSK |= (1 << PCIE);   // pin change interrupt enable
    PCMSK |= (1 << PCINT0); // pin change interrupt enabled for PCINT0
}
