Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set C++ spec on Linux to allow initializer lists #19

Closed
wants to merge 1 commit into from
Closed

Set C++ spec on Linux to allow initializer lists #19

wants to merge 1 commit into from

Conversation

neophiliac
Copy link

Running 'make' on Linux, I get this error.

main.cpp:523:83: error: in C++98 ‘args’ must be initialized by constructor, not by ‘{...}’
     std::vector<TCLAP::Arg*> args = {&packArg, &unpackArg, &listArg, &visualizeArg};

This change allows initializer lists.

@igrr
Copy link
Owner

igrr commented May 8, 2017

That's odd, isn't -std=gnu++11 added in line 2 of the Makefile?

@neophiliac
Copy link
Author

It is, but that didn't prevent the argument list from causing an error. I'm using g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 and I admit that I did not look into the difference between gnu++11 and c++11.

@igrr
Copy link
Owner

igrr commented May 8, 2017

Could you please post the full output you get from make?

@neophiliac
Copy link
Author

2.3.1 /opt/esp8266/mkspiffs master! $ make
g++ -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o main.o main.cpp
main.cpp: In function ‘void processArgs(int, const char**)’:
main.cpp:523:83: error: in C++98 ‘args’ must be initialized by constructor, not by ‘{...}’
std::vectorTCLAP::Arg* args = {&packArg, &unpackArg, &listArg, &visualizeArg};
^
main.cpp:523:83: error: could not convert ‘{(& packArg), (& unpackArg), (& listArg), (& visualizeArg)}’ from ‘’ to ‘std::vectorTCLAP::Arg*’
main.cpp: In function ‘int actionUnpack()’:
main.cpp:448:57: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc);
^
main.cpp: In function ‘int actionList()’:
main.cpp:477:57: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc);
^
main.cpp: In function ‘int actionVisualize()’:
main.cpp:494:57: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
fread(&s_flashmem[0], 4, s_flashmem.size()/4, fdsrc);
^
make: *** [main.o] Error 1
: recipe for target 'main.o' failed

@igrr
Copy link
Owner

igrr commented May 8, 2017

Ok, the argument list doesn't contain -std but contains -march=corei7-avx. Are you adding this argument on the command line or via the CXXFLAGS environment variable?

@neophiliac
Copy link
Author

Here's a more useful one; clearing my local CXXFLAGS first.

2.3.1 /opt/esp8266/mkspiffs master! $ CXXFLAGS= make
g++ -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o main.o main.cpp
cc -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o spiffs/spiffs_cache.o spiffs/spiffs_cache.c
cc -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o spiffs/spiffs_check.o spiffs/spiffs_check.c
cc -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o spiffs/spiffs_gc.o spiffs/spiffs_gc.c
cc -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o spiffs/spiffs_hydrogen.o spiffs/spiffs_hydrogen.c
cc -march=corei7-avx -O2 -pipe -Itclap -Ispiffs -I. -DLINUX -DVERSION="0.1.2-4-g4c41760" -D__NO_INLINE__ -c -o spiffs/spiffs_nucleus.o spiffs/spiffs_nucleus.c
main.cpp: In function ‘void processArgs(int, const char**)’:
main.cpp:523:83: error: in C++98 ‘args’ must be initialized by constructor, not by ‘{...}’
std::vectorTCLAP::Arg* args = {&packArg, &unpackArg, &listArg, &visualizeArg};
^
main.cpp:523:83: error: could not convert ‘{(& packArg), (& unpackArg), (& listArg), (& visualizeArg)}’ from ‘’ to ‘std::vectorTCLAP::Arg*’

@igrr
Copy link
Owner

igrr commented May 8, 2017

Could you please try changing the first two lines of the Makefile to

CFLAGS		+= -std=gnu99 -Os -Wall
CXXFLAGS	+= -std=gnu++11 -Os -Wall

@neophiliac
Copy link
Author

That got rid of the error.

@igrr
Copy link
Owner

igrr commented May 8, 2017

Okay, probably the most reliable way would be

CFLAGS		= -std=gnu99 -Os -Wall $(CFLAGS)
CXXFLAGS	= -std=gnu++11 -Os -Wall $(CXXFLAGS)

so that it is still possible to override some of these flags from the command line, if needed.

@neophiliac
Copy link
Author

OK. I'll close this PR and let you make that change. Thanks!

@neophiliac neophiliac closed this May 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants