Mustafa
Mustafa

Reputation: 37

explicit type is missing ("int" assumed)

i am trying to develop a project with IAR. here is the error message: Error[Pe260]: explicit type is missing ("int" assumed)

Regards.

When i try: void send_data_byte(unsigned char dattt) {
i see a new error: Error[Pe159]: declaration is incompatible with previous "send_data_command"

my sen_data_command function in is on the below

send_data_byte(unsigned char dattt){  
   for(j=0;j<8;j++){  
 pwmstart(1);  
 pwmstop(18);  
  if(dattt & 0x01){  
    __delay_cycles(1687);
  dattt=dattt>>1;  
  }  
 else  
  {  
 __delay_cycles(562); 
   dattt=dattt>>1;  
  }  
  }  
 pwmstop(1);  


  }  
  void send_data_command(unsigned char dat){  

 for (int r=0;r<160;r++)
   {pwmstart(1);}  
 for (int y=0;y<80;y++)
   {pwmstop(1);} 
  send_data_byte(dat);  
  repeat();  
  }  

Upvotes: 1

Views: 9550

Answers (3)

Keith Thompson
Keith Thompson

Reputation: 263457

Old versions of the C language, prior to 1999, had an "implicit int" rule. If you declared a function without specifying the return type, it would be assumed to return a result of type int. The 1999 standard dropped this rule, and made it mandatory to specify the return type on any function declaration or definition. Many compilers cater to old code by permitting such declarations, or by diagnosing them with a non-fatal warning.

Even in pre-1999 C there was no real reason to take advantage of the "implicit int" rule. If a function returns an int result, you can always declare it that way explicitly. (Very old C, before 1989, didn't have void, but support for post-1989 C is essentially universal now.)

As for your other error:

Error[Pe159]: declaration is incompatible with previous "send_data_command"

it indicates that you have two declarations, or a declaration and a definition, of send_data_command, and they differ in some way. There's only one occurrence of send_data_command in your question, so you haven't shown us the code that causes that error. Make sure all references to send_data_command in your program are consistent, and make sure a declaration -- specifically a prototype (which specifies the types of any parameters) -- is visible any time you call it.

(Incidentally, your code would be much easier to read if it were indented properly. There are automated tools that can help you do this. Indentation should reflect the nested structure of your code.)

Upvotes: 1

Niloy Rashid
Niloy Rashid

Reputation: 707

The error message indicate that, you don't explicitly declare any return type of function send_data_type. and it suggesting to put a int before send_data_type. Error massage suggest u to write it in following way:

int send_data_byte(unsigned char dattt) {   

You can also write declare the function as void if you don't need to return anything.

void send_data_byte(unsigned char dattt) {   

There are one more error in your code is that, in function send_data_byte you don't declare j. The following part of the code

send_data_byte(unsigned char dattt){  
for(j=0;j<8;j++){ 

should be,

send_data_byte(unsigned char dattt){  
int j;
for(j=0;j<8;j++){ 

Upvotes: 2

Mureinik
Mureinik

Reputation: 311768

You need to explicitly declare the function's return type. In this case if you have nothing to return, you should declare it as void:

void send_data_byte(unsigned char dattt) {   

Upvotes: 2

Related Questions