The whole point of headers is to expose declarations. If you want your implementation of MOTOR(int,int,int)
to be seen by any source file other than the one in which it is defined, you put it in a header.
Now, if you have another function PWMe(int,int,int)
declared elsewhere then the same thing applies. For the MOTOR
function to be able to call it, you need to expose it in a header. I guess it's defined in mainproj.c
?
motor.h
#ifndef MOTOR_H__
#define MOTOR_H__
void MOTOR( int left, int back, int right );
#endif
mainproj.h
#ifndef MAINPROJ_H__
#define MAINPROJ_H__
extern const char const *one_hit_wonder;
void PWMe( int left, int back, int right );
#endif
Note that in mainproj.h
I've declared a variable as well as a function. Hope you get the idea. Here are the implementations:
mainproj.c
#include "mainproj.h"
const char const *one_hit_wonder = "Yazz";
void PWMe( int left, int back, int right )
{
printf( "The only way is up, baby\n" );
}
motor.c
#include "motor.h"
#include "mainproj.h"
void MOTOR( int left, int back, int right )
{
PWMe( left, back, right );
printf( "For you and me now\n" );
printf( "\n - %s\n", one_hit_wonder );
}
Now, calling MOTOR
with any arguments should produce a catchy chorus from an '80s hit single.