Jump to content
 

PacMan

New Member
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About PacMan

  • Rank
    Newbie
  1. Hi Orunmila. Thank you for the quick reply. The initialization is using something called 'Compound Literals'. It's perfectly valid according to the GCC documentation, but beware, it can be 'dangerous' if you're using C++ (I'm not). Unfortunately, the GCC documentation does not seem to mention how to ensure the compound literals to be in a specific section. -But if anyone would know these things (apart from the compiler developers), it would be developers of embedded software like you. ;) Here's a link to an example, which you may find useful, because initializing this way is really beneficial on small devices: http://nickdesaulniers.github.io/blog/2013/07/25/designated-initialization-with-pointers-in-c/
  2. I have a pointer to a structure and would like to initialize this to point to a structure. The pointer itself should reside in one section, while the structure's data should reside in a different section. The following example puts the pointer in section '.bob', but how do I ensure the structure data is inside section '.frank' ? #define BOB_SECTION __attribute__((section(".bob"))) #define FRANK_SECTION __attribute__((section(".frank"))) struct Cat { uint16_t heads; uint16_t tails; }; BOB_SECTION struct Cat *gNeelix = &((struct Cat){ .heads = 2, .tails = 17 }); -I've tried placing FRANK_SECTION in every place I could think of on the right hand side of the assignment, but I have not succeeded finding a way to get this to happen. What I'm trying to accomplish would be something like the following, but as a pure initializer: FRANK_SECTION static struct Cat sNeelix = { .heads = 2, .tails = 17 }; BOB_SECTION struct Cat *gNeelix = &sNeelix; Am I so lucky that you have any pointers ? :)
×
×
  • Create New...