#include "../std_lib_facilities.h"
int main()
{
constexpr double cm_per_inch = 2.54; // number of centimeters in
// an inch
double length = 1; // length in inches or
// centimeters
char unit = ' '; // a space is not a unit
cout<< "Please enter a length followed by a unit (c or i):\n";
cin >> length >> unit;
if (unit == 'i')
cout << length << "in == " << cm_per_inch*length << "cm\n";
else if (unit == 'c')
cout << length << "cm == " << length/cm_per_inch << "in\n";
else
cout << "Sorry, I don't know a unit called '" << unit << "'\n";
}C:\WINDOWS\system32\cmd.exe /C C:/MinGW64/mingw32/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ ex4 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/User_1/Documents/Coding/ex4'
C:/MinGW64/mingw32/bin/g++.exe -c "C:/Users/User_1/Documents/Coding/ex4/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I.
In file included from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/ext/hash_map:60:0,
from C:/Users/User_1/Documents/Coding/std_lib_facilities.h:34,
from C:/Users/User_1/Documents/Coding/ex4/main.cpp:4:
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
#warning \
^
C:/Users/User_1/Documents/Coding/ex4/main.cpp:7:11: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++0x-compat]
constexpr double cm_per_inch = 2.54; // number of centimeters in
^
C:/Users/User_1/Documents/Coding/ex4/main.cpp: In function 'int main()':
C:/Users/User_1/Documents/Coding/ex4/main.cpp:7:11: error: 'constexpr' was not declared in this scope
C:/Users/User_1/Documents/Coding/ex4/main.cpp:16:51: error: 'cm_per_inch' was not declared in this scope
cout << length << "in == " << cm_per_inch*length << "cm\n";
^
C:/Users/User_1/Documents/Coding/ex4/main.cpp:18:58: error: 'cm_per_inch' was not declared in this scope
cout << length << "cm == " << length/cm_per_inch << "in\n";
^
mingw32-make.exe[1]: *** [Debug/main.cpp.o] Error 1
ex4.mk:97: recipe for target 'Debug/main.cpp.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/User_1/Documents/Coding/ex4'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====4 errors, 3 warnings====
C:/MinGW64/mingw32/bin/g++.exe -c "C:/Users/User_1/Documents/Coding/ex4/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I.
-c = create object
-g = debug option
-O0 = optimization
-Wall = see all warnings
-o = name of output
-I = include directory
With modifications the Codelite will do:
C:/MinGW64/mingw32/bin/g++.exe -std=c++11 -c "C:/Users/User_1/Documents/Coding/ex4/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I.
If your compiler supports, you can add -std=c++14 instead.
Without -std=c++11/-std=c++14 almost all code in the book will not work.
C:/MinGW64/mingw32/bin/g++.exe -std=c++11 -c "C:/Users/User_1/Documents/Coding/ex4/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I.
I pasted that into command prompt and it got this
In file included from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/ext/hash_map:60:0,
from C:/Users/User_1/Documents/Coding/std_lib_facilities.h:34,
from C:/Users/User_1/Documents/Coding/ex4/main.cpp:4:
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
#warning \
^
In file included from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/locale:41:0,
from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/iomanip:43,
from C:/Users/User_1/Documents/Coding/std_lib_facilities.h:212,
from C:/Users/User_1/Documents/Coding/ex4/main.cpp:4:
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/bits/locale_facets_nonio.h:1971:5: error: template-id 'do_get<>' for 'String std::__cxx11::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const' does not match any template declaration
messages<char>::do_get(catalog, int, int, const string&) const;
^
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/bits/locale_facets_nonio.h:1971:62: note: saw 1 'template<>', need 2 for specializing a member function template
messages<char>::do_get(catalog, int, int, const string&) const;
^I have no idea what it means. I looked into ./Debug/main.cpp.o for output and expected an exe file but its not there? I don't really know how to use the command line. There are so many things I don't know yet, so all of these seems very confusing. Next thing I put -std=c++11 into Codelite and this pops up.
C:\WINDOWS\system32\cmd.exe /C C:/MinGW64/mingw32/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ ex4 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/User_1/Documents/Coding/ex4'
C:/MinGW64/mingw32/bin/g++.exe -c "C:/Users/User_1/Documents/Coding/ex4/main.cpp" -g -O0 -std=c++11 -Wall -o ./Debug/main.cpp.o -I. -I.
In file included from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/ext/hash_map:60:0,
from C:/Users/User_1/Documents/Coding/std_lib_facilities.h:34,
from C:/Users/User_1/Documents/Coding/ex4/main.cpp:4:
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
#warning \
^
In file included from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/locale:41:0,
from C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/iomanip:43,
from C:/Users/User_1/Documents/Coding/std_lib_facilities.h:212,
from C:/Users/User_1/Documents/Coding/ex4/main.cpp:4:
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/bits/locale_facets_nonio.h:1971:5: error: template-id 'do_get<>' for 'String std::__cxx11::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const' does not match any template declaration
messages<char>::do_get(catalog, int, int, const string&) const;
^
C:/MinGW64/mingw32/i686-w64-mingw32/include/c++/bits/locale_facets_nonio.h:1971:62: note: saw 1 'template<>', need 2 for specializing a member function template
messages<char>::do_get(catalog, int, int, const string&) const;
^
mingw32-make.exe[1]: *** [Debug/main.cpp.o] Error 1
ex4.mk:97: recipe for target 'Debug/main.cpp.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/User_1/Documents/Coding/ex4'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====2 errors, 4 warnings====
You got idea what is happening ? Also where can I learn more about the command line?