Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > ANSI prototype Error

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



ANSI prototype Error
Moderator:
RKRM

Post Reply
Follow this topic



ANSI prototype Error

AlExAndEr posted on 05 Jul 2012 1:46 PM PST

1 Forum Post

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.




Re: ANSI prototype Error

danaaknight posted on 05 Jul 2012 01:50 PM PST
Top Contributor
1773 Forum Posts

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

function call :

 

void iDAC11_SetValue( uint16 ) ;

.

.

.

main() {

..

..

..

}

 

Regards, Dana.



Re: ANSI prototype Error

danaaknight posted on 05 Jul 2012 01:52 PM PST
Top Contributor
1773 Forum Posts

Also make sure your IDAC component is named IDAC1, not

IDAC1_1_......

 

Regards, Dana



Re: ANSI prototype Error

Bob Marlowe posted on 05 Jul 2012 02:06 PM PST
Top Contributor
1768 Forum Posts

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

 

 

 



Re: ANSI prototype Error

danaaknight posted on 05 Jul 2012 04:24 PM PST
Top Contributor
1773 Forum Posts

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

 

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

 

Regards, Dana.



Re: ANSI prototype Error

Suresh R posted on 31 Jul 2012 02:27 AM PST
Member
2 Forum Posts

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

 

 

 

 

 

 

 



Re: ANSI prototype Error

danaaknight posted on 31 Jul 2012 04:29 AM PST
Top Contributor
1773 Forum Posts

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.



Re: ANSI prototype Error

Suresh R posted on 07 Aug 2012 12:32 AM PST
Member
2 Forum Posts

 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



Re: ANSI prototype Error

H L posted on 07 Aug 2012 04:25 AM PST
Top Contributor
679 Forum Posts

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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20