I've written a very small 'Hello world' project that uses timer interrupts to flash a LED at 1 Hz. This works well. However I'm now trying to move functions into separate header and source files.
I have a "system.h" and "system.c" file for system commands (IO config, oscillator selection etc).
In main.c I call #include system.h and all is well, now in system.c I also #include system .h as well and this is where everything falls over and gives me the following error "error: multiple sections using address 0x1fffa". This is actually a linker issue that refers to configuration words in the PIC that goes away if you remove one of the #include system.h statements.
I bet you are not only declaring objects (variables, config bits) in the header but also defining them. This seems to be true at least for an object defined like
__code __at(0x1fffa) uint8_t stuff = 123;
Of course, without the contents of system.h this is impossible to know...
Move everything that does not have an extern declarator or does have an initializer to the .c file, keep and/or provide only prototypes/declarations in the header.
Oh: If you include the header in two separately compiled .c files, the header include guards do not help. They only guard against including the same file multiple times in the same .c file, typically indirectly via other headers. This is not a compiler bug.
Last edit: Raphael Neider 2014-09-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your reply. I did have my '#pragma config' statements in the header file and have now moved them into .c source files instead of the header file and all is well.
Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
I'm using SDCC with codeblocks for development.
I've written a very small 'Hello world' project that uses timer interrupts to flash a LED at 1 Hz. This works well. However I'm now trying to move functions into separate header and source files.
I have a "system.h" and "system.c" file for system commands (IO config, oscillator selection etc).
In main.c I call #include system.h and all is well, now in system.c I also #include system .h as well and this is where everything falls over and gives me the following error "error: multiple sections using address 0x1fffa". This is actually a linker issue that refers to configuration words in the PIC that goes away if you remove one of the #include system.h statements.
My system.h file looks like this:
Build Tools:
SDCC 3.4.0 x64
GPUTILS 1.3
CodeBlocks 13.12
What am I doing wrong?
Conoral11
Last edit: Raphael Neider 2014-09-26
I bet you are not only declaring objects (variables, config bits) in the header but also defining them. This seems to be true at least for an object defined like
Of course, without the contents of system.h this is impossible to know...
Move everything that does not have an
externdeclarator or does have an initializer to the .c file, keep and/or provide only prototypes/declarations in the header.Oh: If you include the header in two separately compiled .c files, the header include guards do not help. They only guard against including the same file multiple times in the same .c file, typically indirectly via other headers. This is not a compiler bug.
Last edit: Raphael Neider 2014-09-26
Raphael,
Thank you for your reply. I did have my '#pragma config' statements in the header file and have now moved them into .c source files instead of the header file and all is well.
Thank you!