dimanche 11 octobre 2020

Why is stoi causing an error and how to fix in Makefile

I have been trying to run a code that uses stoi, below is the makefile, each time I run this code I get an 'error: 'stoi' was not declared in this scope', any idea how I can include the C++11 compiler in the make file

#compile and link the application
all: main

#run the application
run: main
./main

#link main.o, time.o, and date.o to excutuable main, with debug messages 
and functions visible
debug: temp.o day.o cal.o
g++ -g -c -Duse_debug main.cpp
g++ -g -o main main.o temp.o day.o cal.o

#link main.o, temp.o, and day.o to executable main
main: main.o temp.o day.o cal.o
g++ -g -o main main.o temp.o day.o cal.o 

#compile the main.cpp to main.o
main.o: main.cpp
g++ -g -c main.cpp

#compile the temp.cpp to temp.o
temp.o: temp.cpp
g++ -g -c temp.cpp

#compile the day.cpp to day.o
day.o: day.cpp
g++ -g -c day.cpp

#compile the cal.cpp to cal.o
cal.o: cal.cpp
g++ -g -c cal.cpp

#remove built files
clean:
rm -rf main main.o temp.o day.o cal.o *~ 

Here's a sample code of the part the uses stoi,

#include <iostream>    //cin and cout
#include <string>    //stoi(), getline()
#include <cctype>    //isdigit()
using namespace std;

int main()
{
string inputS;
cin>> inputS;
input = stoi(inputS);    //converts inputStr to int type
return 0;
}
 

Aucun commentaire:

Enregistrer un commentaire