Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:27:17+00:00 2026-06-06T22:27:17+00:00

Consider this code: enum { ERR_START, ERR_CANNOTOPENFILE, ERR_CANNOTCONNECT, ERR_CANNOTCONNECTWITH, ERR_CANNOTGETHOSTNAME, ERR_CANNOTSEND, }; char* ERR_MESSAGE[]

  • 0

Consider this code:

enum 
{
        ERR_START,
        ERR_CANNOTOPENFILE, 
        ERR_CANNOTCONNECT, 
        ERR_CANNOTCONNECTWITH,
        ERR_CANNOTGETHOSTNAME,
        ERR_CANNOTSEND,

};

char* ERR_MESSAGE[] =
{
    [ERR_START]                     = "Nothing",
    [ERR_CANNOTOPENFILE]            = "Cannot open '%s' filename.\n",
    [ERR_CANNOTCONNECT]             = "Cannot connect.\n",
    [ERR_CANNOTCONNECTWITH]         = "Cannot connect with '%s'.\n",
    [ERR_CANNOTGETHOSTNAME]         = "Cannot get host name.\n",
    [ERR_CANNOTSEND]                = "Cannot send.\n",

};

Given this erros:

error.h:27:1: error: parameter ‘ERR_MESSAGE’ is initialized
error.h:29:2: error: array index in non-array initializer
error.h:29:2: error: (near initialization for ‘ERR_MESSAGE’)
error.h:29:2: warning: initialization from incompatible pointer type
error.h:30:2: error: array index in non-array initializer
[....]

I’m compiling with -std=c99.

How to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:27:18+00:00Added an answer on June 6, 2026 at 10:27 pm

    I think you are getting this message because another syntax error in the file (or something included before it). I pasted the code into a standalone C file and got no compile errors with gcc -std=c99 -c test.c and my GCC version is gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2).

    A likely error (maybe the only one) is if there’s a function declaration that is missing a semicolon. With the code

    enum 
    {
            ERR_START,
            ERR_CANNOTOPENFILE, 
            ERR_CANNOTCONNECT, 
            ERR_CANNOTCONNECTWITH,
            ERR_CANNOTGETHOSTNAME,
            ERR_CANNOTSEND,
    
    };
    
    void foo()
    char* ERR_MESSAGE[] =
    {
        [ERR_START]                     = "Nothing",
        [ERR_CANNOTOPENFILE]            = "Cannot open '%s' filename.\n",
        [ERR_CANNOTCONNECT]             = "Cannot connect.\n",
        [ERR_CANNOTCONNECTWITH]         = "Cannot connect with '%s'.\n",
        [ERR_CANNOTGETHOSTNAME]         = "Cannot get host name.\n",
        [ERR_CANNOTSEND]                = "Cannot send.\n",
    
    };

    I get the similar errors

    est.c: In function ‘foo’:
    test.c:13:1: error: parameter ‘ERR_MESSAGE’ is initialized
    test.c:15:5: error: array index in non-array initializer
    test.c:15:5: error: (near initialization for ‘ERR_MESSAGE’)
    test.c:15:5: warning: initialization from incompatible pointer type [enabled by default]
    test.c:15:5: warning: (near initialization for ‘ERR_MESSAGE’) [enabled by default]
    test.c:16:5: error: array index in non-array initializer
    test.c:16:5: error: (near initialization for ‘ERR_MESSAGE’)
    test.c:16:5: warning: excess elements in scalar initializer [enabled by default]
    test.c:16:5: warning: (near initialization for ‘ERR_MESSAGE’) [enabled by default]
    [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code: const char* someFun() { // ... some stuff return Some text!!
Consider this code: char *strs[] = { string1, string2, NULL }; char *ptr1 =
Consider this code segment: char message[255]; char newMessage[255]; int i; for (i = 0
Consider this code: public interface Foo extends Comparable<Foo> {} public enum FooImpl implements Foo
Consider this code: if(initscr() == NULL) ERROR(Cannot start ncurses mode.\n); keypad(stdscr, TRUE); cbreak(); int
Consider this code: char buffer[] = abcdefghijklmnopqrstuvwxyz, *val = malloc(10), *pbuf = buffer, *pval
Consider this code: txtLastModifyUserID.DataBindings.Add(Text, c_bsDataSetSource, LastModifyUserID); txtLastModifyUserID.Text = 1234; Why cannot the source be
Consider this code: new Ajax.Request('?service=example', { parameters : {tags : 'exceptions'}, onSuccess : this.dataReceived.bind(this)
Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new
Consider this code: import socket store = [] scount = 0 while True: scount+=1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.