LinuxQuestions.org
Review your favorite Linux distribution.
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, 09:59 AM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,742

Rep: Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877
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 10:03 AM.
 
Old 10-07-2017, 10:37 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,876

Rep: Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908Reputation: 2908
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, 11:57 AM   #3
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,742

Original Poster
Rep: Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877
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, 08:36 AM   #5
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,742

Original Poster
Rep: Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877
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


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

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

All times are GMT -5. The time now is 05:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration