CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Program structure- whats wrong:*** Error 112 "F:\CCS_Fe

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Program structure- whats wrong:*** Error 112 "F:\CCS_Fe
PostPosted: Sun Jul 09, 2006 5:20 am     Reply with quote

I wrote a lot of programms with only one C-file. Now I want to structure my program but it doesnīt work. I always get this error:
*** Error 112 "F:\CCS_Feheler\Display.c" Line 31(0,1): Function used but not defined: ... main

This is the MAIN.C:

#include <16F877>
#include "main.h"
#include "Display.h"


int Command_int;
int Data_int;

void main (void)
{

set_tris_e(0x00);
set_tris_d(0x00);

Display_Command ( 63 ); // Display an (62 + 63)

for (;;)
{
output_high(CS1);
output_low(CS2);
Write_Display_Data ( 0x00 );
output_low(CS1);
}

}





This is the DISPLAY.C:

#include <16F877>
#include "main.h"
#include "Display.h"


void Display_Command ( Command_int )
{
output_low(ENABLE);
output_low(R_W);
output_low(D_I);
output_d(Command_int);
delay_us(1);
output_high(ENABLE);
delay_us(1);
output_low(ENABLE);
}

void Write_Display_Data ( Data_int )
{
output_low(ENABLE);
output_low(R_W);
output_high(D_I);
output_d(Data_int);
delay_us(1);
output_high(ENABLE);
delay_us(1);
output_low(ENABLE);
}




This is the MAIN.H:

void main ( void );

#FUSES HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD,NOWRT
#use delay(clock=16000000)

#use STANDARD_IO (A)
#use STANDARD_IO (B)
#use STANDARD_IO (C)
#use FAST_IO (D)
#use FAST_IO (E)

#use I2C(MASTER, SDA=PIN_C4, SCL=PIN_C3, SLOW, FORCE_HW)

#define CS1 PIN_C1
#define CS2 PIN_C0
#define RESET PIN_E0
#define R_W PIN_C5
#define D_I PIN_E2
#define ENABLE PIN_E1




This is the DISPLAY.H:

//---------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------

void Display_Command ( Command_int );
void Write_Display_Data ( Data_int );



I donīt understand it: the main function is defined in Main.c - isnīt it?
Ttelmah
Guest







PostPosted: Sun Jul 09, 2006 9:02 am     Reply with quote

The simple answer is that you cannot/must not 'prototype' the main function.

Best Wishes
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Sun Jul 09, 2006 9:05 am     Reply with quote

Your prototypes aren't correct. You need to explicitly specify the datatype in your prototypes.

Code:
void Display_Command(Command_int)

should be
Code:
void Display_Command(int Command_int)

both in your header file and at the start of your subroutine.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Sun Jul 09, 2006 10:08 am     Reply with quote

... if you add the variable type to your function prototypes, you then don't need the declarations at the top of main :

Code:

int Command_int;
int Data_int;


as these are not required as 'global' variables.
_________________
Regards,
Simon.
epideath



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

PostPosted: Sun Jul 09, 2006 10:38 am     Reply with quote

All of the above are needed but also With CCS you need to tell the compiler to load the seperate C files

So you need to use

#include "Display.c" instead of "Display.h".

Once that the C file is loaded then the functions will be loaded and they don't necessarily have to be prototyped as they get loaded before the call to them.
But it doesn't hurt to have the prototype as something may change in the future or if you wanted to port this to some other compiler at some time.

But as far as multiple source files CCS basically looks at them as one big C file.

Hope that makes sense.

Regards
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group