ANSI prototype Error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

  I am new to PSOC and i am facing error  "requires ANSI-style prototype".

   

This is the code

   

#include <device.h>
#include "stdio.h"
#include "math.h"

/* Number of samples to be taken before averaging the ADC value */
void main()
{
  
/* Start both DACs */
IDAC1_MSD_Start();
IDAC2_LSD_Start();
/* Sets both IDACs to source current */
IDAC1_MSD_SetPolarity(IDAC1_MSD_SOURCE);
IDAC1_MSD_SetPolarity(IDAC2_LSD_SOURCE);
/* Sets proper ranges */
IDAC1_MSD_SetRange(IDAC1_MSD_RANGE_2mA );
IDAC2_LSD_SetRange(IDAC2_LSD_RANGE_255uA);

   

/*facing problem in this line*/
iDAC11_SetValue(12) ;
}
/* 11-Bit SetValue function. */
void iDAC11_SetValue(uint16 dacValue)
{
    uint8 msb, lsb;
    /* Split data into 2 bytes */
    msb = (uint8)(dacValue >> 3);
    lsb = (uint8)((dacValue << 0) & 0x07);
    /* Write values */
    IDAC1_MSD_SetValue(msb);
    IDAC2_LSD_SetValue(lsb);    
}
Please reply ASAP its urgent.

0 Likes
8 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Before main() declaration in listing declare the prototype for the

   

function call :

   

 

   

void iDAC11_SetValue( uint16 ) ;

   

.

   

.

   

.

   

main() {

   

..

   

..

   

..

   

}

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Also make sure your IDAC component is named IDAC1, not

   

IDAC1_1_......

   

 

   

Regards, Dana

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Today's C-language needs to know what kind of rerturn-value and what parameters a function has before it is called the first time. This is named "declaration" of a function prototype. It has the form

   

returntype FunctionName(Parametertypelist);

   

Usually to improve parameter understanding, a name can be posted after a parametertype which is meaningless for code generation but improves readability, for example

   

BOOL GetValveState(uint16 PressureValue);

   

 

   

main()

   

   while GetValveState(OutSideBar) ...

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Actually C does allow a parameterless prototype, but good compilers complain.

   

 

   

http://en.wikipedia.org/wiki/Function_prototype

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Dana, Thanks for helping to fix the PSOC related compilatation errors.

   

I also had same issue of " requires ANSI-style prototype"  in my  PSOC3 compilation.

   

I made a mistake of not declaring function call before main(). After  I have declared function call correctly as below before main()

   

void   PIN_3V3_BCM_ON_write(uint8)

   

the error "ERROR: .\main.c:100: 'PIN_3V3_BCM_ON_write': requires ANSI-style prototype
The command 'c51.exe' failed with exit code '2' is disappeared.

   

Thanks,

   

Suresh

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Did you terminate the declaration with a ";" ?

   

 

   

Another possibility, you mispelled the call in the code after declaration.

   

 

   

Some compilers complain about a line number, and it's actually the prior

   

line of code that is at issue.......

   

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Dana, Yes.. I had  ";" after decleration

   

   

void   PIN_3V3_BCM_ON_write(uint8); 

   

 

   

and actually there was no mispel/case senstive change for this call in my code after decleration.

   

 

   

Thanks,

   

Suresh

   

     

0 Likes
Anonymous
Not applicable

 How about upload your project so people here can check for you. 

0 Likes