Error : Initializer element is not constant.

Discussion in 'Mac Programming' started by mkristain, Aug 21, 2011.

  1. mkristain macrumors regular

    Joined:
    Aug 18, 2011
    #1
    Hello i have this error in my application.

    Code:
    //define this in abc header class
    #define	XYZ_TEST
    
    //and use struct in other test.c class
    const struct types_test types_t[] = {
      { XYZ_TEST, 			"xyz test"		}//here error occured.
    };
    
    
    thanks.
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    So what does

    #define XYZ_TEST

    mean? Read up on the rules for macro evaluation. What happens exactly when XYZ_TEST is ued in your source code?
     
  3. dmi macrumors regular

    Joined:
    Dec 21, 2010
    #3
    Since XYZ_TEST is defined to be blank, your code expands to
    Code:
    const struct types_test types_t[] = {
      { , "xyz test" }
    };
    
     

Share This Page