c++ - Making g++ point this error/Warning out -



c++ - Making g++ point this error/Warning out -

i had statement this

std::string student::returndata() { // homecoming "this homecoming type" ; std::cout << "hello world"; }

however when built c++ project such

entry: main.o student.o g++ -w -wall -werror -o $@ main.o student.o main.o: g++ -w -wall -werror -c main.cpp clean: rm -rf *.o entry

i wasnt given warning/error , when method executed output started going crazy suggestions on could warned silly mistakes these

gcc emit error flags -wall -werror. problem don't have rule target student.o, , implicit rules not utilize warning flags. simplest approach might set warning flags globally, , allow implicit rules thing. can achieved using cxxflags variable (or cflags c code):

cxxflags += -wall -werror

this take care of student.o , .o doesn't have explicit rule. note rule makes student.o implicitly dependent on student.cpp, student.ccor student.c. can add together dependencies without modifying recipe this:

student.o: student.h # student.o depends on student.h

this result in error of form

error: no homecoming statement in function returning non-void [-werror=return-type]

i suggest adding wextra warning flag.

c++ make g++

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -