Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
C headers, modular programming and linking
I have a problem when trying to compile a program with multiple modules. I've made an Abstract Data Type and placed all the declarations and function prototypes into a header "hwconf.h" . The implementation of the ADT is in a different file "hwconf.c" where I included the header. To test this module I've made a simple program "cli.c".
The problem is that when I try to compile the whole program I get a linker error, seeing multiple declarations of the constants defined in "hwconf.h". I tried to figure out what's wrong and I found out that the C compiler , unlike the c++ one, it actualy allocates memory for the constants. How can I avoid the linker error, without usig the "#define" dirrective ? What are the standards for C headers?
0 · ·