Global variables initialization in C - required or standards-compliance?

Discussion in 'Programmer's Corner' started by dor, Jan 10, 2010.

  1. dor

    Thread Starter Active Member

    Feb 20, 2009
    I read that in order to be compatible with the ANSI C standards, a C programmer must initialize all global variables before main() (which means: before program execution).

    But is this required for the program to work correctly?
    The code is hosted on a MCU EEPROM.

    Thank you :)
  2. sceadwian

    New Member

    Jun 1, 2009
    Results will be unpredictable if anything in main itself or a function call from main needs the global variable before it's declared.