Search code examples
carduinopwm

implicit declaration of function even though i have included the file?


my project is almost working but i get 1

Warning: "implicit declaration of function 'init_phase_correct' [-Wimplicit-function-declaration]"

have have the function called in my main

int main(void)
{
    volatile char start_flag=0;
  uart0_Init ( MYUBRRF );
  DDRB |=(1<<PB7);
  sei();  //enable global interrupt
  initAdc();      
  data = 'a';
  ADCSRA |=(1<<ADIE);
  init_phase_correct();

and init_phase_correct is included i the top in

#include "PWM.h"

that links to

/*
 * IncFile1.h
 *
 * Created: 23-04-2015 11:30:38
 *  Author: Martin Egsdal
 */ 


#ifndef INCFILE1_H_


#define INCFILE1_H_

extern void init_fastPWM();
extern void init_phase_correct();
extern void init_ph_frPWM();
extern void init_phase_correct_alt();


#endif /* INCFILE1_H_ */

and in the C file it is:

void init_phase_correct(){
TCCR0A|=(1<<COM0A1)|(1<<WGM00); //Clear OC0A on Compare Match when up-counting. Set OC0A on Compare Match when down-counting
TCCR0B =(1<<CS01);   //prescalling by 8 
OCR0A =102;  //40 duty cycle    
TCNT0= 0;
DDRB |= (1<<DDB7);// configure OC0A pin for output  
}

when i rightclick init_phase_correct() in my main i can see the 2 implentations - so why is it "Wimplicit-function-declaration"?


Solution

  • I see, that your header file, which contains declaration of init_phase_correct() is wrapped with include guard with some auto-generated name (INCFILE1_H_).

    Also, you did not specify, whether init_phase_correct() is declared inside PWM.h or maybe another file, that is included by PWM.h.

    Without more code, I cannot say for sure, but my clairvoyance skill tells me, that INCFILE1_H_ may be used as include guard in another file - either PWM.h itself or another, that is being included before file, that contains declaration of init_phase_correct().