Avoiding #ifdefs

Marek Vasut marek.vasut at gmail.com
Wed Jan 6 03:02:06 EST 2010


Dne St 6. ledna 2010 07:46:59 CoDeBrEaKeR napsal(a):
> Thanks,
> 
>  But the stucture am using is pretty insanely nested.

So? Why don't you show us the real code? (please also stop top-posting).
> 
> ~A
> 
> --- On Wed, 1/6/10, Marek Vasut <marek.vasut at gmail.com> wrote:
> > From: Marek Vasut <marek.vasut at gmail.com>
> > Subject: Re: Avoiding #ifdefs
> > To: linux-arm at lists.infradead.org
> > Cc: "CoDeBrEaKeR" <codebreaker28 at yahoo.com>
> > Date: Wednesday, January 6, 2010, 11:53 AM
> > Dne St 6. ledna 2010 07:04:37
> >
> > CoDeBrEaKeR napsal(a):
> > > Most of the times its is easy to start having a lot of
> >
> > #ifdef statements in
> >
> > >  your code. Since this is not a proper thing to
> >
> > do, placing the #ifdef in a
> >
> > >  header file would be the usual suggestion. well,
> >
> > i understand this as far
> >
> > >  as #ifdefs in functions are concerned. How about
> >
> > structures?
> >
> > > for Ex:
> > >
> > >  static struct something = {
> > >     .name       
> >
> >            = "xyz",
> >
> > >     .driver_name     
> >
> >       = "something",
> >
> > > #ifdef SOME_ARCH_TYPE
> > >     .bla       
> >
> >             = DO_THIS,
> >
> > > #else
> > >     .bla       
> >
> >             =
> > DO_SOMETHING_ELSE,
> >
> > > #endif
> > > };
> > >
> > > How do i avoid #ifdef here, any idea??
> >
> > If you want to do some run-time detection, then do so and
> > assign 'bla' at
> > runtime...
> > if (x)
> >  something.bla = somefn;
> > else
> > ...
> >
> > > Thanks.
> > >
> > > ~A
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > linux-arm mailing list
> > > linux-arm at lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/linux-arm
> >
> > _______________________________________________
> > linux-arm mailing list
> > linux-arm at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm
> 



More information about the linux-arm mailing list