Hitech compiler Compile issue

Status
Not open for further replies.

nayakajit87

Member level 5
Joined
Aug 13, 2018
Messages
84
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
1,065
I am using PIC16F886 with hitech compiler 9.60. Here is below code i am trying to compile.
If i am using compiler v9.86 that is free version below code compile properly and do proper working.
If i am using Pro version of compiler v 9.60 i used to get error. Error are attached below. How to get raid of this issue. How variable should be declared.



Code:
#include <pic.h>
#include <htc.h>
#include "delay.h"

__CONFIG(INTIO & WDTEN & PWRTEN & MCLREN & UNPROTECT & BOREN & IESODIS & FCMDIS & LVPDIS & DEBUGDIS);
__CONFIG (BORV40 & WP2);
//__EEPROM_DATA(0,0,0,0,0,0,0,0);




 typedef union 
     {
         struct
         {
            unsigned S0 :1;
            unsigned S1 :1;
            unsigned S2 :1;
            unsigned S3 :1;
            unsigned S4 :1;
            unsigned S5 :1;
            unsigned S6 :1;
            unsigned S7 :1;
         };
         unsigned char S0_7; 
     }USensor;
         
     USensor sen;
     unsigned char a;
         
     void main (void)
     {
         for(;;)
         {
             sen.S0 = 1;
             sen.S1 = 0;
             sen.S2 = 1;
             sen.S3 = 0;
             sen.S4 = 1;
             sen.S5 = 0;
             sen.S6 = 1;
             sen.S7 = 0;
             
             a = sen.S0_7;
         }
     }


Error msg

Code:
Error   [285] C:\Users\Testing\Test.c; 25.2 no identifier in declaration
Error   [255] C:\Users\Testing\Test.c; 36.8 not a member of the struct/union ""
Error   [255] C:\Users\Testing\Test.c; 37.8 not a member of the struct/union ""
Error   [255] C:\Users\\Testing\Test.c; 38.8 not a member of the struct/union ""
 

S0 is not a member of sen, so you can't write "sen.S0".
S0 is a part of a struct inside sen, but the struct has no name.
Give the struct a name.
If you call the struct "my_bit_struct", you can then write "sen.my_bit_struct.S0"
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…