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

LVL 2
asmyattAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
Does it still error if you change the name FS for something else (e.g. foo)?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brian UtterbackPrinciple 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.
0
asmyattAuthor Commented:
wow that was easy...I suppose FS is reserved? Thanks!
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

evilrixSenior Software Engineer (Avast)Commented:
Indeed, hence my suggestion to try another name.
0
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 .
0
Infinity08Commented:
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;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.