c++11 - C++ Cannot find Include -
in main.cpp
keep getting errors saying print
not defined (and other errors of sort.
i have print()
defined under header file called "misc"
misc.h
#include <iostream> #include <cstdlib> #include <fstream> #define misc_h #ifndef misc_h void print(string str) { cout << str << endl; } string userin(string prompt = "option:") { //for collecting user responses string response; print(prompt); cin.clear(); cin.sync(); getline(cin, response); if (!cin) { response = "wtf"; } else if (response == "512") { //secret termination code print("program terminated"); exit(0); } print(""); return response; } #endif
then in main.cpp
#include headers/misc.h"
(the header file located in separate folder)
is there i'm doing wrong here?
what's visible me, without knowing compile commands using, 'include guard' incorrect.
the first command #define misc_h
cause macro begin existing.
after that, when call #ifndef misc_h
false, because have defined it, effect source of file discarded.
you need flip lines this:
#ifndef misc_h #define misc_h
Comments
Post a Comment