Solaris g++ error with typedef and map

I am porting some c++ code from windows to Solaris. I have deduced my problems to basically my typedef statements. Below is a small sample that will not compile and I cannot figure out why:

Below is how I compile it and the output I get:

g++ ./Test1.cpp -o Test1
Test1.cpp: In function `int main()':
Test1.cpp:12: error: expected primary-expression before numeric constant
Test1.cpp:12: error: expected `;' before numeric constant

#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef map<int, int>	MyMap;
int main()
	MyMap FS;
	return 0;

Open in new window

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
Does it still error if you change the name FS for something else (e.g. foo)?
Brian UtterbackConnect With a Mentor Principle Software EngineerCommented:
The obvious thing is that the symbol FS is a defined macro somewhere in your include
files. It looks from the error messages that it is defined to something that evaluates
to a constant.
asmyattAuthor Commented:
wow that was easy...I suppose FS is reserved? Thanks!
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

evilrixSenior Software Engineer (Avast)Commented:
Indeed, hence my suggestion to try another name.
Brian UtterbackPrinciple Software EngineerCommented:
Reserved is a rather difficult concept. The namespace for macros is a little loose. In general, macro writers should
try to avoid using any more names than necessary to avoid conflicts. But using anything that is defined in your include files in a way other than the way intended in the files is asking for trouble. Alas, figuring out what
is defined is the tough part. Usually you just have to forge ahead and be aware of the problem. Then if something
weird happens, (as it did for you) see if the errors look like something was redefined .
It would not have occurred if the variable name didn't consist of all capital characters.

It's good practice to have your variable names start with a lower case character, like :

        int anInteger;
        float value;
        map<int, int> fs;
        long someOtherVariable;
All Courses

From novice to tech pro — start learning today.