LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 08-24-2017, 01:01 PM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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

Last edited by BW-userx; 08-24-2017 at 01:03 PM.
 
Old 08-24-2017, 01:07 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Code:
const char *mount_opts[] =
{
  "ro",
  "rw",
  "rsize",
  "wsize",
  NULL
};
 
Old 08-24-2017, 01:26 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by NevemTeve View Post
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’)|

Last edited by BW-userx; 08-24-2017 at 01:33 PM.
 
Old 08-24-2017, 02:12 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by BW-userx View Post
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 View Post
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?

Last edited by astrogeek; 08-24-2017 at 03:26 PM. Reason: Added "what to post" para, grammer changes
 
Old 08-24-2017, 03:38 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by astrogeek View Post
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 ---
 
Old 08-24-2017, 04:26 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by BW-userx View Post
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.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] C: Using an array element as index to another array? stf92 Programming 1 08-23-2015 11:26 PM
C array of structures keeps saying initializer element not constant knobby67 Programming 5 04-08-2015 10:17 AM
[SOLVED] [C++] error: array must be initialized with a brace-enclosed initializer MTK358 Programming 11 07-01-2011 05:50 PM
[SOLVED] gcc Warning: Array index has type 'char' traene Programming 4 04-20-2008 08:43 PM
const array parameter warning in GCC JoeyAdams Programming 2 09-06-2007 03:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration