#def question

From: ashish (ashishgupta82_at_gmail.com)
Date: 08/25/04


Date: 25 Aug 2004 14:42:49 -0700

Hello,

Supposing I have a #def like so ..

#define A 10

Now A has been used everywhere in the code.

In loops ... for (i=0; i < A; i++)

And defines ...

int charArray[A];

And in structures

struct a {
   int intarray[a];
};

Now, I want to define a variable B such that ..

#define B ( (my_mode) ? 20 : A)

Basically, B will be A (10 if my_mode is 0 (old) or 20 if my_mode is 1
(new).

Obviously this creates a problem with the integer array and the
structure definitions - I think I can do this only if it is a function
or in the for loop as above.

Is there any way I can achieve this or will I have to hardcode
#define B 20 and live with

int charArray [20]; etc. in all modes .

TIA



Relevant Pages

  • [tip:x86/cleanups] x86: Clean up mtrr/cleanup.c
    ... static int __init ... save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek, ... unsigned long base, size, def, dummy; ...
    (Linux-Kernel)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is the assignment ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int & result) ...
    (microsoft.public.vc.mfc)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int ...
    (microsoft.public.vc.mfc)
  • Re: does Ruby not support multiple "initialize" methods for a class???
    ... two "initialize" methods with their own specific method signature to cover ... def initialize *argv, &block ... def initialize_from_int int ... def initialize template ...
    (comp.lang.ruby)
  • Re: structure and malloc
    ... ABC *abc; ... memoryfor structure DEF and its constituting structure ABC. ...
    (comp.lang.c)