Problem fixed! Thanks a lot for the constructive suggestions!
I am unable to figure out what is the mistake in the following code. Is there something wrong with the way I am doing includes?
// This is utils.h
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <fstream>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef stack<int> si;
typedef queue<int> qi;
#define tr(c,i) for(typeof((c).begin()) i = (c).begin() ; i!=(c).end() ; ++i )
#define all(c) (c).begin(),(c).end()
#define cpresent(c,x) (find(all(c),x) != (c).end())
#endif
// ==============================================================
// Below is main.cpp
#include "utils.h"
int main() {
vi v;
}
On compiling "g++ main.cpp" I get the following error message:
utils.h:13: error: expected initializer before ‘<’ token utils.h:14: error: expected initializer before ‘<’ token utils.h:15: error: expected initializer before ‘<’ token utils.h:16: error: expected initializer before ‘<’ token utils.h:17: error: expected initializer before ‘<’ token utils.h:18: error: expected initializer before ‘<’ token main1.cpp: In function ‘int main()’: main1.cpp:4: error: ‘vi’ was not declared in this scope main1.cpp:4: error: expected `;' before ‘v’
What is wrong with this code? The utils.h used to work fine some time back when I did not have the #ifndefs in it.