LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 10-07-2017, 08:59 AM   #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
what? --> note: synthesized method 'options::options()' first required here


In C++11, I have a struct here:
header:
Code:
typedef struct {
int i = 0;
int g = 0;

//to be compatible with vector.size() return data type
unsigned long int leftoff = 0;

char *path = nullptr; <-- I'm assuming that is right instead of NULL.

//holds file names
std::vector<std::string> dfile; <-- I have no idea how to initialize that

}options;


extern options opts;
Quote:
/media/data/projects/VSC/C++/codeblocks/mh5000/mh5000/options.h|21|warning: 'options::dfile' should be initialized in the member initialization list [-Weffc++]|
I got most of the list initialization (since C++11) thing figured out (kind of) except for that vector<string>, but I too am getting what that title says here in the cpp. it is not saying anything about my other struct set up the same with a lot more data in it, not yet anyways.

in the options.cpp it references this-> note: synthesized method 'options:: options()' first required here. (no space between the colons, I get a 'O' face if I keep it like that. )
Code:
options opts;
options:: options() <--- it is not a class it is a strut, don't let that little bit of knowledge fool you about my limited amount on this subject.

Last edited by BW-userx; 10-07-2017 at 09:03 AM.
 
Old 10-07-2017, 09:37 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
use: [noparse]options::options()[/noparse] to avoid faces

post at least something usable, to be able to reproduce what you are talking about. What I can see is syntactically incorrect and therefore useless. How do you think anyone will be able to tell you what's wrong with your real code?
 
Old 10-07-2017, 10:57 AM   #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 pan64 View Post
use: [noparse]options::options()[/noparse] to avoid faces

post at least something usable, to be able to reproduce what you are talking about. What I can see is syntactically incorrect and therefore useless. How do you think anyone will be able to tell you what's wrong with your real code?
that's it my whole struct just stick it in a header file and make a main then compile it.

oh for you:
main
Code:
#include <iostream>
#include "strt.h"
int main(){
options opts;
return 0;
}
a header file
Code:
#ifndef STRT_H
#define STRT_H

#include <vector>
typedef struct {
int i = 0;
int g = 0;

//to be compatible with vector.size() return data type
unsigned long int leftoff = 0;
char *path = NULL;
//holds file names
std::vector<std::string> dfile;
}options;

extern options opts;
#endif
run
Code:
g++ -Weffc++ *.cpp
gets
Code:
[userx@void gurp]$ g++ -Weffc++ *.cpp
In file included from dummy.cpp:2:0:
strt.h: In constructor 'options::options()':
strt.h:18:2: warning: 'options::dfile' should be initialized in the member initialization list [-Weffc++]
 }options;
  ^~~~~~~
dummy.cpp: In function 'int main()':
dummy.cpp:5:10: note: synthesized method 'options::options()' first required here
  options opts;
          ^~~~
 
Old 10-09-2017, 12:58 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
http://www.geeksforgeeks.org/when-do...zer-list-in-c/
https://www.cprogramming.com/tutoria...lists-c++.html
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55837
 
Old 10-09-2017, 07:36 AM   #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
well that last one explains everything, doesn't it?
I was actually thinking of just removing that or downgrading the standardization.
thanks for that last link.

makes me wonder what -W checks are really be trusted.
 
  


Reply



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] Need to update Note 2 to Android-5+. Options? business_kid Linux - Mobile 11 09-22-2017 08:40 PM
Comprehensive Details on Linux kernel compile options required. s.verma Linux - General 4 03-19-2014 09:14 AM
Proper make options and gcc options for my particular processor CyclicFlux Linux - General 1 08-17-2012 07:49 PM
[SOLVED] modifying stream id of ip options Error options (unknown 136) MegaMindd Programming 0 06-07-2011 09:17 AM
Method to batch resize photos with options michapma Linux - Software 10 02-08-2010 09:49 AM

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

All times are GMT -5. The time now is 05:52 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