LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   warning: empty declaration| |error: parameter ‘mount_opts’ is initialized| error: array index in non-array initializer|... (https://www.linuxquestions.org/questions/programming-9/warning-empty-declaration%7C-%7Cerror-parameter-%91mount_opts%92-is-initialized%7C-error-array-index-in-non-array-initializer%7C-4175612570/)

BW-userx 08-24-2017 01:01 PM

warning: empty declaration| |error: parameter ‘mount_opts’ is initialized| error: array index in non-array initializer|...
 
I do not no longer have any idea what to put i here to show anyone what it is I am looking at, or doing to give me the errors I am getting so I will just use the exact example that is now giving me the very same errors. when what I was using following the example was working just fine until hours later of coding. then all of a sudden it just started giving me these complaints and errors and no longer compiling completely.

the errors are in that title
Code:

enum
{
  RO_OPTION = 0,
  RW_OPTION,
  READ_SIZE_OPTION,
  WRITE_SIZE_OPTION,
  THE_END
};

const char *mount_opts[] =
{
  [RO_OPTION] = "ro",
  [RW_OPTION] = "rw",
  [READ_SIZE_OPTION] = "rsize",
  [WRITE_SIZE_OPTION] = "wsize",
  [THE_END] = NULL
};

DOCUMENTATION
https://www.gnu.org/software/libc/ma...ptions-Example

NevemTeve 08-24-2017 01:07 PM

Code:

const char *mount_opts[] =
{
  "ro",
  "rw",
  "rsize",
  "wsize",
  NULL
};


BW-userx 08-24-2017 01:26 PM

Quote:

Originally Posted by NevemTeve (Post 5751638)
Code:

const char *mount_opts[] =
{
  "ro",
  "rw",
  "rsize",
  "wsize",
  NULL
};


Your example completely make that enum pointless, so what is the entire purpose of GNU and it telling me that their way is the correct way, especially when it was working and now you are showing me that GNU them grurs that invented coding (C) or something to do with it anyways are wrong?

thanks I will now give your example a try. BRB

NOPE:

Code:


const char *tile_opts [] =
{
  "n",
  "h",
  "v",
  "hv",
  "r",
  "rh",
  "rv",
  "rhv",
  "st",
  NULL

};

Code:

||=== Build: Debug in mh (compiler: GNU GCC Compiler) ===|

/media/data/C-Projects/mh/mh/options.c|50|error: parameter ‘tile_opts’ is initialized|
/media/data/C-Projects/mh/mh/options.c|52|warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]|
/media/data/C-Projects/mh/mh/options.c|52|note: (near initialization for ‘tile_opts’)|
/media/data/C-Projects/mh/mh/options.c|53|warning: excess elements in scalar initializer|
/media/data/C-Projects/mh/mh/options.c|53|note: (near initialization for ‘tile_opts’)|


astrogeek 08-24-2017 02:12 PM

Quote:

Originally Posted by BW-userx (Post 5751636)
I do not no longer have any idea what to put i here to show anyone what it is I am looking at, or doing to give me the errors I am getting

You need to post a clear problem description based on the result of your own troubleshooting, the point at which you are stuck. Include the minimal code example which your own troubleshooting produced and which reproduces the specific problem, in isolation (independent of your application code as much as possible). See the Site FAQ, again, especially this, What makes a good issue description?.

Quote:

Originally Posted by BW-userx (Post 5751636)
I will just use the exact example that is now giving me the very same errors. when what I was using following the example was working just fine until hours later of coding. then all of a sudden it just started giving me these complaints and errors and no longer compiling completely.

Is the code that you posted the actual code giving you the error, or is it just the example that your own code is based on?

Code:

The original was...

const char *mount_opts[] =
{
  ... values
};

Is now...

const char *tile_opts [] =
{
  ... different values
};

The different value list would also probably mean that the enum declaration is different. Which is it?

Quote:

..working just fine until hours later of coding. then all of a sudden it just started giving me these complaints and errors and no longer compiling...
That is not a useful problem description.

When things have been working then suddenly begin producing errors, obviously something has changed. At that point you need to stop and look at what you had done between when it did work and when it did not.

What have you done to identify the changes? What have you done to troubleshoot and isolate the actual problem other than post here?

BW-userx 08-24-2017 03:38 PM

Quote:

Originally Posted by astrogeek (Post 5751656)
You need to post a clear problem description based on the result of your own troubleshooting, the point at which you are stuck. Include the minimal code example which your own troubleshooting produced and which reproduces the specific problem, in isolation (independent of your application code as much as possible). See the Site FAQ, again, especially this, What makes a good issue description?.

it is either one way or the other with you it seems

too much information, no its not enough information.

Quote:



Is the code that you posted the actual code giving you the error, or is it just the example that your own code is based on?

Code:

The original was...

const char *mount_opts[] =
{
  ... values
};

Is now...

const char *tile_opts [] =
{
  ... different values
};

The different value list would also probably mean that the enum declaration is different. Which is it?



That is not a useful problem description.

When things have been working then suddenly begin producing errors, obviously something has changed. At that point you need to stop and look at what you had done between when it did work and when it did not.
I got fed up with trying to find it so I just striped it out ---

astrogeek 08-24-2017 04:26 PM

Quote:

Originally Posted by BW-userx (Post 5751685)
I got fed up with trying to find it so I just striped it out ---

Without ever showing effort to troubleshoot your code nor to answer our questions.

So here we are again, another pointless, dead-end BW-userx thread in the LQ Programming forum.

You have been asked multiple times to end this posting pattern, and have been directed to the LQ posting guidelines, along with patient explanation of what you should include, and not include, in your posts. You have either ignored, or at the very least not demonstrated any effort to learn or apply those simple guidelines to your posts here.

This thread is being closed and you are being warned strongly that this pattern must end now.

From the Site FAQ to which you have been repeatedly referred:

Quote:

If you are unwilling or unable to ask questions in a manner that allows us to help you, it's unlikely our community will be able to provide you a solution. Unfortunately, serial offenders who show wanton disregard for this request after multiple pointers may be asked to seek help elsewhere. We truly hope that isn't necessary...
That is the ultimate endpoint toward which we are now headed. No one wants to get there, least of all myself. Please make effort to understand and apply the principles necessary for continued participation in these forums.


All times are GMT -5. The time now is 02:25 AM.