"initializer element not constant" issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zoeb
    New Member
    • Jul 2008
    • 17

    "initializer element not constant" issue

    Hi,

    I am declaring an array which carries x coordinates, however these will vary depending on the geometry the user enters.

    I have set my code up as follows, but get the "initialize r element not constant" issue. I had the code compiling earlier, but made the mistake of moving thing aorund without taking a backup and now nothing works!

    Any help would be greatly appreciated.

    /*============== =============== =============== ===========*/
    #include <stdio.h>
    #include <stdlib.h>
    #include <grx20.h>

    /*Declare types of parameters entered */
    float x1, x2, x3, yone, y2, y3;
    float x23;
    int NoMembers, NoNodes;


    main()

    {

    x1 = 4;
    x2 = 2;
    x3 = 6;
    yone = 4;
    y2 = 10;
    y3 = 14;


    x23 = 6;

    }

    float x1co[] = {-x1, x1, x1, -x23, -x23, x23, x23, -x2, x2, x2, -x3, -x2, x2, x3};

    /*============== =============== =============== ======*/
  • curiously enough
    New Member
    • Aug 2008
    • 79

    #2
    Well everything I'm seeing here should work fine, so the problem's most likely in a part of your program that is not posted here.

    Comment

    • zoeb
      New Member
      • Jul 2008
      • 17

      #3
      Thanks for the help, I copied it into another source file and it compiled no problem! Thanks anyway!

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by zoeb
        Thanks for the help, I copied it into another source file and it compiled no problem! Thanks anyway!
        That wasn't the problem: the first time you tried to compile it as if it were a C file;
        the last time you used a C++ compiler.

        kind regards,

        Jos

        Comment

        Working...