variable initialisation


    Sep 01 2006 | 9:34 am
    What is the difference between initializing the variables at the beginning of the code, and initializing the variables in the main() function ?
    best
    f.e -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|

    • Sep 01 2006 | 6:41 pm
      On 1-Sep-2006, at 11:34, f.e wrote: > What is the difference between initializing the variables at the > beginning of the code, and initializing the variables in the main() > function ?
      In the first case the compiler generates whatever code is necessary to initialize the variable before the first explicit line of main() is called.
      In general I prefer to initialize variables before main(), to avoid doing something stupid like using the variable two lines before the first assignment (modern compilers will warn about this, but they used not to!)
      Note that you can't use a function call like gensym() for initialization. Still, it's a good idea to explicitly initialize to NULL in the variable definition and then assign the gensym() result early in your code.
      Also, C (unlike Pascal) doesn't force you to put the intialization at the top of the file. Extern and static declarations/definitions can occur anywhere. But don't do that;-
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de