This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

include file

hello everyone,
i am writing a program for c8051f020,in which i have 4 ".c" files: main c file,keyroutine file, general routines files,confguration file

i separated bit addressable, data addressable, functions, #defines in separate header files

i included these header files in respective ".c" file

but i am getting following error in linking

1. public refers to ignored segment
2.address space overflow both for data as well as bit memory
3.multiple public definitions

i have put all ".c" files for build
shall i continue or main c file should be put for building

if i do so then for debugging i will not be able to put breakpoint in other c files

can you tell me how to include c file in another c file

for further details pls let me know

thank you all
take care

Parents
  • Just a follow-up about guard code for defines and guard code around individual symbols.

    Guard code around an individual symbol may seem good, but have a big implication:

    lib_header_1.h

    #if !defined(MY_CONSTANT)
    #define MY_CONSTANT 10
    #endif
    

    lib_header_2.h

    #if !defined(MY_CONSTANT)
    #define MY_CONSTANT 20
    #endif
    

    source_file_alt1.c

    #include "lib_header_1.h"
    #include "lib_header_2.h"
    int my_data[MY_CONSTANT];
    

    source_file_alt2.c

    #include "lib_header_2.h"
    #include "lib_header_1.h"
    int my_data[MY_CONSTANT];
    

    The end result will be an application that behaves differently depending on the include order of the two header files, and the developer will have no good way of figuring out why.

    It is better if a library function either has a really hard limit, or is written to take the limit at run time.

    But for a nother case - guarding full header files.

    comlib_type_defines.h

    typedef unsigned char comlib_uchar;
    

    comlib_protocol1.h

    void library1_function(comlib_uchar a);
    

    library_protocol2.h

    void library2_function(comlib_uchar a);
    

    Now it would be nice if an end user may use either library_protocol1, or library_protocol2 or both, without having to know that the two protocol libraries have a common part with a common header file, i.e. all four examples should be allowed:

    example_only_1.c

    #include "comlib_protocol1.h"
    
    ...
    

    example_only_2.c

    #include "comlib_protocol2.h"
    
    ...
    

    exampley_both_a.c

    #include "comlib_protocol1.h"
    #include "comlib_protocol2.h"
    
    ...
    

    example_both_b.c

    #include "comlib_protocol2.h"
    #include "comlib_protocol1.h"
    
    ...
    

    But it is important to note that comlib_protocol1.h, comlib_protocol2.h and the common file comlib_type_defines.h may not play with conditionally defined symbols. As soon as the end user is allowed to replace the value of an individual symbol, the developer got a vey big loaded gun preaimed at his/her own foot.www

Reply
  • Just a follow-up about guard code for defines and guard code around individual symbols.

    Guard code around an individual symbol may seem good, but have a big implication:

    lib_header_1.h

    #if !defined(MY_CONSTANT)
    #define MY_CONSTANT 10
    #endif
    

    lib_header_2.h

    #if !defined(MY_CONSTANT)
    #define MY_CONSTANT 20
    #endif
    

    source_file_alt1.c

    #include "lib_header_1.h"
    #include "lib_header_2.h"
    int my_data[MY_CONSTANT];
    

    source_file_alt2.c

    #include "lib_header_2.h"
    #include "lib_header_1.h"
    int my_data[MY_CONSTANT];
    

    The end result will be an application that behaves differently depending on the include order of the two header files, and the developer will have no good way of figuring out why.

    It is better if a library function either has a really hard limit, or is written to take the limit at run time.

    But for a nother case - guarding full header files.

    comlib_type_defines.h

    typedef unsigned char comlib_uchar;
    

    comlib_protocol1.h

    void library1_function(comlib_uchar a);
    

    library_protocol2.h

    void library2_function(comlib_uchar a);
    

    Now it would be nice if an end user may use either library_protocol1, or library_protocol2 or both, without having to know that the two protocol libraries have a common part with a common header file, i.e. all four examples should be allowed:

    example_only_1.c

    #include "comlib_protocol1.h"
    
    ...
    

    example_only_2.c

    #include "comlib_protocol2.h"
    
    ...
    

    exampley_both_a.c

    #include "comlib_protocol1.h"
    #include "comlib_protocol2.h"
    
    ...
    

    example_both_b.c

    #include "comlib_protocol2.h"
    #include "comlib_protocol1.h"
    
    ...
    

    But it is important to note that comlib_protocol1.h, comlib_protocol2.h and the common file comlib_type_defines.h may not play with conditionally defined symbols. As soon as the end user is allowed to replace the value of an individual symbol, the developer got a vey big loaded gun preaimed at his/her own foot.www

Children
No data