Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio warning C4133

getting a weird warning in Visual Studio 2005:

warning C4133: '=' : incompatible types - from 'PointNode *' to 'PointNode *'

struct definition:

struct PointNode {
  int x;
  int y;
  struct PointNode *next;
};

declaration and usage:

struct PointNode* pPointHead;
...

pPointHead = pPointHead->next;

The warning itself says they are the same types, why would it complain?

(unfortunately i can't tag C4133)

like image 510
user320781 Avatar asked Aug 16 '11 23:08

user320781


1 Answers

Your struct should look like this:

struct PointNode {
  int x;
  int y;
  PointNode *next; // remove struct keyword
};

Declare and use like this:

PointNode *pPointHead; // remove struct keyword
pPointHead->next;

When you add the struct keyword, the compiler thinks that you are declaring a new different struct with the same name.

like image 173
philipvr Avatar answered Sep 26 '22 15:09

philipvr