• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Control initialised data layout?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Control initialised data layout?


  • Subject: Re: Control initialised data layout?
  • From: Greg Guerin <email@hidden>
  • Date: Mon, 30 Jul 2007 10:07:07 -0700

Martin Crane wrote:

>static unsigned char gBuffer1[8] = { 'a', 'b', 'c', 'd', 'e', 'f',
>'g', 'h'};
>unsigned char gBuffer2[8] = { 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'};

How about defining it as a struct, whose layout you can control.  A struct
is what should have been done in the first place.

typedef struct gbuff
  { unsigned char buf1[8]; unsigned char buf2[8]; }
  gbuff;

static gbuff gBuffer12 = {
  { 'a', 'b', 'c', 'd', 'e', 'f',  'g', 'h'},
  { 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'}  };

Refer to gBuffer1 as:
  gBuffer12.buf1

You can #define substitutions, too:
  #define gBuffer1  (gBuffer12.buf1)
  #define gBuffer1  (gBuffer12.buf2)

to reduce the amount of changes needed to source that refers to it.

I'm assuming the external scanner app is not using the symbol-names
gBuffer1 or gBuffer2.  If it were, that'd be a problem, although it may be
more readily solvable than the layout one.

(All code typed in mail, not compiled or tested.)

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Control initialised data layout?
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Using Xcode debugger without Xcode project
  • Next by Date: Disable Localization?
  • Previous by thread: Re: Control initialised data layout?
  • Next by thread: Re: Control initialised data layout?
  • Index(es):
    • Date
    • Thread