-2

I'm trying to implement a function about drawing a circle

void drawCircle(const circleType * circle)

Above is displayed how it's defined in the header file. I'm trying to use it in a program:

drawCircle(circle);

The circle is a struct (circleType) of 3 variables, each and every one defined before calling the procedure. Am I doing something obviously wrong? The error I'm getting is:

320 Cannot assign 'circle' to 'circle'
307 Illegal typecast 'can not convert to pointer' ''

IDE is mikroC PRO for AVR (v4.60.0.0). I aren't sure of the compiler included. Should also mention that I only get the error when optimization is set to 0 (otherwise, I simply get 'finished with errors' without any error message)

Nognir616
  • 1
  • 3

1 Answers1

2
void drawCircle(const circleType * circle)

expects a pointer to, the address of a circleType typed variable.

So assuming

typedef struct 
{  
  int xc; 
  int yc; 
  int rc; 
} circleType;

...

circleType circle = {...};

You want to call the function like this

drawCircle(&circle);

using the address-of operator & to gain circle's address.

alk
  • 69,737
  • 10
  • 105
  • 255
  • xc and yc are directly assigned values, while rc is calculated before assigned. Calling `drawCircle(&circle)` returns `Illegal pointer conversion` error message – Nognir616 Sep 22 '15 at 06:26
  • @Nognir616: If this does not solve your issue(s?), you won't get around to provide more info, typically an MCVE (http://stackoverflow.com/help/mcve). – alk Sep 22 '15 at 07:01