View previous topic :: View next topic |
Author |
Message |
wileur
Joined: 29 Apr 2014 Posts: 2
|
Dereferencing pointer, no compiler warning |
Posted: Tue Apr 29, 2014 7:23 am |
|
|
I'm using structs, and pointers to structs, and found that the compiler is not warning about the following case:
Code: |
typedef struct TEST {
uint8_t member;
} TEST;
TEST var;
TEST *pointer = &var;
var.member = 5; // Correct
var->member = 5; // Wrong, and compoler throws an error
pointer->member = 5; // Correct
pointer.member = 5; // Wrong, but no error
|
On other platforms I would be greeted by an error and quickly fix it. But here I get no message at all. Is it silently overlooked by the compiler (very serious) or is it accepted and somehow referenced correctly anyway (less serious, but confusing)?
The manual does list compiler error messages, but nothing about this. Google only led to this forum,... Searching here didn't produce anything either. Anyone that knows?
I'm using CCS PCD V1.435. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Tue Apr 29, 2014 7:31 am |
|
|
It just puts the 5, directly into pointer.
It has been pointed out here many hundreds of times that the syntax checking in CCS is appalling. I syntax check using a different compiler, with a suite of special macros, so it doesn't throw a wobbly about the CCS constructs. Tools like lint are also commonly used.
It has slowly (too slowly) improved.
Report it to CCS. |
|
|
wileur
Joined: 29 Apr 2014 Posts: 2
|
|
Posted: Wed Apr 30, 2014 7:02 am |
|
|
Thanks, I'll look at lint. What compiler do you use?
I'll report it to CCS though. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Apr 30, 2014 2:39 pm |
|
|
It's a commercial IBM one. I wrote part of it, so did my own custom 'core', and some syntax macros, that make it able to emulate the CCS compiler. Only problem is they keep changing things. Upgrading to make it work with V5, was an exercise.... |
|
|
|