Overloading functions and conflicting datatypes

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, using Atmel Studio 7 on Win10. I'm also using an ASF C example project as the starting point of this project (sets the state of the LED to the state of a button), with the SAMD21 Xplained Dev board. The example works, compiles, and runs. It's the code I add to this example that I'm having problems with.

 

First problem: method / function overloading. I have the following code:

 

void LCD_Write_Bus(char VH, char VL)
{
	REG_PORT_OUTCLR1 = 0x0000ffff;
	REG_PORT_OUTSET1 = (VH >> 8) | VL;
	REG_PORT_OUTCLR1 = LCD_WR;
	REG_PORT_OUTSET1 = LCD_WR;
}

void LCD_Write_COM(char VH, char VL)
{
	REG_PORT_OUTCLR1 = LCD_DC;
	LCD_Write_Bus(VH,VL);
}

void LCD_Write_COM(char VL)
{
	REG_PORT_OUTCLR1 = LCD_DC;
	LCD_Write_Bus(0x00, VL);
}

The prototypes for these functions are defined above the main(void) function. The problem is with overloading the functions. Is it possible to overload functions in Atmel Studio. The exact error I'm getting is, "too many arguments to function LCD_Write_COM'. Normally this isn't a problem, because you can overload functions.

 

The second problem is with data types. The code:

 

LCD_Write_COM(0xD5,0x00);

produces an error of " conflicting types for 'LCD_Write_COM'  "

 

I have tried every iteration I can think of, from to declaring the function as char, unsigned char, signed char, uint8_t, int8_t.... basically, I'd like to know how to pass 0xF0 into a function. Thank you for your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you writing C or C++ ? Only C++ does overloading...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's being written in C, because ASF does not work with C++. 

 

This issue has been fixed by just renaming the functions:

 

LCD_Write_COM16(char VH, char VL)

LCD_Write_COM8(char VL)