+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Member level 3
    Points: 489, Level: 4

    Join Date
    Aug 2018
    Posts
    61
    Helped
    0 / 0
    Points
    489
    Level
    4

    Hitech compiler Compile issue

    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 ""

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 4
    Points: 7,571, Level: 20
    Achievements:
    7 years registered

    Join Date
    Jul 2010
    Location
    Sweden
    Posts
    1,013
    Helped
    387 / 387
    Points
    7,571
    Level
    20

    Re: Hitech compiler Compile issue

    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"



--[[ ]]--