Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Distributed array initialization

Reply
Thread Tools

Distributed array initialization

 
 
Christopher Collins
Guest
Posts: n/a
 
      01-07-2013
On 2013-01-04, Shao Miller <(E-Mail Removed)> wrote:
> Your particular implementation might have extensions for doing this. If
> you're not too concerned about portability, then that's fine.
>
> The iPXE source code does just what you're trying to do. You can see
> the discussion in ipxe/src/include/ipxe/tables.h[1]. Essentially, the
> strategy involves linker magic.
>
> - Shao Miller
>
> [1] https://git.ipxe.org/ipxe.git/blob/H.../ipxe/tables.h


Thanks, Shao (and everyone else who responded). Luckily, I don't
actually require this type of array initialization; I just thought it
would be nice to have. A linker trick like this is a little further
than I am willing to go, but it is interesting to see how it is done.

I think I will just use initialization functions. With compound
literals, it won't be too hard to tell what data the arrays (of structs)
are being populated with.
 
Reply With Quote
 
 
 
 
gwowen
Guest
Posts: n/a
 
      01-07-2013
On Jan 7, 8:55*am, Christopher Collins <(E-Mail Removed)>
wrote:
>
> Thanks, Shao (and everyone else who responded). *Luckily, I don't
> actually require this type of array initialization; I just thought it
> would be nice to have. *A linker trick like this is a little further
> than I am willing to go, but it is interesting to see how it is done.


Just as non-standard, but possibly slightly more palatable than linker
magic, GCC gives you the attribute((constructor)) to declare a
function that should be called before main().
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
initialization of array as a member using the initialization list aaragon C++ 2 11-02-2008 04:57 PM
array initialization in initialization list. toton C++ 5 09-28-2006 05:13 PM
Initialization of non-integral type in initialization list anongroupaccount@googlemail.com C++ 6 12-11-2005 09:51 PM
Initialization via ctor vs. initialization via assignment Matthias Kaeppler C++ 2 07-18-2005 04:25 PM
Default Initialization Vs. Value Initialization JKop C++ 10 09-22-2004 07:26 PM



Advertisments