Compilation error : Please help

state_field state_abvr[] = {
"AL","ALABAMA",
"AK","ALASKA",
"AZ","ARIZONA",
"AR","ARKANSAS",
"CA","CALIFORNIA",
"CO","COLORADO",
"CT","CONNECTICUT",
"DE","DELAWARE",
"DC","DISTRICT-OF-COLUMBIA",
"FL","FLORIDA",
"GA","GEORGIA",
"HI","HAWAII",
"ID","IDAHO",
"IL","ILLINOIS",
"IN","INDIANA",
"IA","IOWA",
"KS","KANSAS",
"KY","KENTUCKY",
"LA","LOUISIANA",
"ME","MAINE",
"MD","MARYLAND",
"MA","MASSACHUSETTS",
"MI","MICHIGAN",
"MN","MINNESOTA",
"MS","MISSISSIPPI",
"MO","MISSOURI",
"MT","MONTANA",
"NE","NEBRASKA",
"NV","NEVADA",
"NH","NEW-HAMPSHIRE",
"NJ","NEW-JERSEY",
"NM","NEW-MEXICO",
"NY","NEW-YORK",
"NC","NORTH-CAROLINA",
"ND","NORTH-DAKOTA",
"OH","OHIO",
"OK","OKLAHOMA",
"OR","OREGON",
"PA","PENNSYLVANIA",
"PR","PUERTO-RICO",
"RI","RHODE-ISLAND",
"SC","SOUTH-CAROLINA",
"SD","SOUTH-DAKOTA",
"TN","TENNESSEE",
"TX","TEXAS",
"UT","UTAH",
"VT","VERMONT",
"VI","VIRGIN-ISLANDS",
"VA","VIRGINIA",
"WA","WASHINGTON",
"WV","WEST-VIRGINIA",
"WI","WISCONSIN",
"WY","WYOMING"
};
int num_states = XtNumber(state_abvr);

some where arond line no 1000:

varibale defined like this:

extern state_field state_abvr[];

but while compiling this code i am getting
below error:

cc: "cd_globals.c", line 1000: error 1000: Unexpected symbol: "state_abvr".

please help me how to resolve this error

I am using the above one in another file for test functionality :

code is like this:

/*/
int test_state_abvr(char *string)
/
/
{
int i, j, k;
char st[2];

#ifdef DEBUG
printf("at cd_string.c - ");
printf("in function - test_state_abvr\n");
printf("string = %s\n", string);
printf("num_states = %d\n", num_states);
#endif

for ( i=0;i<num_states;i++ ) {
strncpy(st, state_abvr[i].abvr, 2);
st[2] = 0;

#ifdef DEBUG
printf("i = %d ", i);
printf("st = %s ", st);
printf("state_abvr[i].abvr = %s ", state_abvr[i].abvr);
printf("state_abvr[i].state = %s\n", state_abvr[i].state);
#endif

    if \( strcmp\(string, st\) == 0 \) \{
            return 1;
            /*** state found - OK ***/
            \}
    \}

    /*** state NOT found - NOT OK ***/
    return 0;

}

while compiling this file i am getting error:

bosdf9d1:root make
/opt/ansic/bin/cc -c -Ae +DA1.0 +DS1.0 -DX11R5 -Aa -D_INCLUDE_HPUX_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_AES_SOURCE -I/bto/bcs/shared/include -I/bto/sys/BCS/usr/include -I/usr/include -I/bto/bcs/maint -I/usr/local/include -lc -lPW -I/usr/include/X11R5 -I/usr/include/Motif1.2 -I/usr/BCSshared -c cd_string.c
cc: "/usr/include/sys/time.h", line 530: warning 618: Declaration of "timeval" not visible outside this function prototype scope.
cc: "/usr/include/sys/time.h", line 542: warning 618: Declaration of "timeval" not visible outside this function prototype scope.
cc: "cd_globals.c", line 1000: error 1000: Unexpected symbol: "state_abvr".
cc: "cd_string.c", line 408: error 1588: "state_abvr" undefined.
cc: "cd_string.c", line 408: error 1529: Cannot select field of non-structure.
cc: "cd_string.c", line 408: warning 563: Argument #2 is not the correct type.
cc: "cd_string.c", line 408: warning 527: Integral value implicitly converted to pointer in assignment.
cc: "cd_string.c", line 408: warning 563: Argument #3 is not the correct type.
cc: "cd_string.c", line 431: error 1000: Unexpected symbol: "/".
*** Error exit code 1

need help in resolving this issue

Hi,

I do not understand your problem very well, but If you are defining the variable state_field state_abvr[] as a global variable in the same file where you are using test_state_abvr function, you do not need to declare it as extern.

You should define a variable as extern, if it is global and if you want use it from another function defined in another file.

Hope it helps!