bdata across multiple files?

I have data that I would like to efficiently address as both a byte and as 8 bits.
The bdata type sounds like the way to go, but I can not make it work across multiple files.
This program fails to compile and link. Any ideas?

// main.h
extern char bdata Main_Bits;
sfr Main_Bit0 = Main_Bits ^ 0;

//main.c 
#include "main.h"
char bdata Main_Bits;

void FnA( void );  
void main( void )
{
  Main_Bits = 0;
  FnA();  
}

//FnA.c 
#include "main.h"
void FnA( void )
{
  Main_Bit0 = 1;
}

Parents
  • Sorry, I really did mean to type sbit.
    Anyways, using sbit, I get the following errors.

    Build target 'Target1'
    compiling Main.C...
    MAIN.H(3): error C142: 'Main_Bits': invalid base address
    compiling FnA.c...
    MAIN.H(3): error C142: 'Main_Bits': invalid base address
    .\FNA.C(5): error C202: 'Main_Bit0': undefined identifier
    Target not created
    
    The code files are:
    // main.h
    extern char bdata Main_Bits;
    sbit Main_Bit0 = Main_Bits ^ 0;
    
    //main.c 
    #include "main.h"
    char bdata Main_Bits;
    
    void FnA( void );  
    void main( void )
    {
      Main_Bits = 0;
      FnA();  
    }
    
    //FnA.c 
    #include "main.h"
    void FnA( void )
    {
      Main_Bit0 = 1;
    }
    


Reply
  • Sorry, I really did mean to type sbit.
    Anyways, using sbit, I get the following errors.

    Build target 'Target1'
    compiling Main.C...
    MAIN.H(3): error C142: 'Main_Bits': invalid base address
    compiling FnA.c...
    MAIN.H(3): error C142: 'Main_Bits': invalid base address
    .\FNA.C(5): error C202: 'Main_Bit0': undefined identifier
    Target not created
    
    The code files are:
    // main.h
    extern char bdata Main_Bits;
    sbit Main_Bit0 = Main_Bits ^ 0;
    
    //main.c 
    #include "main.h"
    char bdata Main_Bits;
    
    void FnA( void );  
    void main( void )
    {
      Main_Bits = 0;
      FnA();  
    }
    
    //FnA.c 
    #include "main.h"
    void FnA( void )
    {
      Main_Bit0 = 1;
    }
    


Children
More questions in this forum