I am facing an issue in creating multiple sections in a .c file. I wants to place code for task1 in section .task1 and code for task2 in section .task2
Consider the following code: case 1:
#include <stdio.h>
/* Variables for task 1 */
int task1_a;
char task1_b;
/* Variables for task 2 */
int task2_a;
char task2_b;
If I use attribute section as below it works fine. case 2:
#include <stdio.h>`
__attribute__ ((section (".task1"))) int task1_a;
__attribute__ ((section (".task1"))) char task1_b;
__attribute__ ((section (".task2"))) int task2_a;
__attribute__ ((section (".task2"))) char task2_b;
but what I want is like: case 3:
#include <stdio.h>
__attribute__ ((section (".task1")))
int task1_a;
char task1_b;
__attribute__ ((section (".task2")))
int task2_a;
char task2_b;
So that all the time we do not need to write attribute ((section (".xyz"))) in front of all the variables or functions.
While compiling case 3 compiler is throwing an error:
error: section of 'task2_a' conflicts with previous declaration
int task2_a
Is there any way to end the section before starting new section. My understanding is that it should automatically end if we start a new section but it is not happening.
I am using arm-unknown-eabi-gcc version 4.8.4 for compilation.