473,378 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

typedef Syntax Error

I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA
struct CSTYPE
{ // City/State Record
string csKey; // City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;

Oct 31 '08 #1
14 3378
On Oct 31, 2:01*pm, mrc2...@cox.net (Mike Copeland) wrote:
* *I'm getting a syntax error on the "typedef" code line here. *Any
thoughts on why? *TIA

struct CSTYPE
{ * * * * * * * * * * * * * * * * * ** * * * *// City/State Record
* * * * string csKey; * * * * * * * * * * ** * *// City/State "Key"
* * * * string csCity; * * * * * * * * * * * * * * * * * * * // City
* * * * string csState; * * * * * * * * * * * * * * * *// State Code};

typedef map<string, CSTYPECSINFO; *// <=== error here
* * * * extern CSINFO cityStInfo;
* * * * extern map<string, CSTYPE>::iterator csIter;
* * * * extern CSTYPE workCS;

1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?
Oct 31 '08 #2
red floyd wrote:
On Oct 31, 2:01 pm, mrc2...@cox.net (Mike Copeland) wrote:
> I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE
{ // City/State Record
string csKey; // City/State "Key"
string csCity; // City
string csState; // State Code};

typedef map<string, CSTYPECSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;


1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?
It's possible that his compiler does not allow the use of incomplete
types as template arguments, even in typedefs, and 'CSTYPE' is
incomplete at that point...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 31 '08 #3
Mike Copeland wrote:
I'm getting a syntax error on the "typedef" code line here.
....

The following appears to work as expected w/GCC 4.

#include <map>
#include <string>

using std::map;
using std::string;

// TODO: Expand "cs" to something more meaningful.
namespace cs {

// TODO: Give this type a more meaningful name.
struct type {
string key;
string city;
string state;
};

typedef map<string, typeinfo;
}

#include <iostream>

int main() {

cs::info info;

info["hello"].key = "world";
info["foo"].key = "bar";

std::cout << info["hello"].key << '\n';
std::cout << info["foo"].key << '\n';
}
Oct 31 '08 #4
I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE
{ // City/State Record
string csKey; // City/State "Key"
string csCity; // City
string csState; // State Code
}; <==== this was in my post, but was appended to the above line.

typedef map<string, CSTYPECSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;

1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?

It's possible that his compiler does not allow the use of incomplete
types as template arguments, even in typedefs, and 'CSTYPE' is
incomplete at that point...
Yes, but please see my common above. I _thought_ I had a complete
declaration for CSTYPE - am I wrong?
Oct 31 '08 #5
I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE // City/State Record
{
string csKey;// City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <= error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;


1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?
I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{
I also didn't state that this is in a common .h file I'm building
(and I apologize for not mentioning that...)
Oct 31 '08 #6
On Oct 31, 10:16*pm, Victor Bazarov <v.Abaza...@comAcast.net>
wrote:
red floyd wrote:
On Oct 31, 2:01 pm, mrc2...@cox.net (Mike Copeland) wrote:
I'm getting a syntax error on the "typedef" code line here.
*Any thoughts on why? *TIA
struct CSTYPE
{ * * * * * * * * * * * * * * * * * * * * * * *// City/State Record
* * * * string csKey; * * * * * * * * * * * * * *// City/State "Key"
* * * * string csCity; * * * * * * * * * ** * * * * * * * * // City
* * * * string csState; * * * * * * * * * * * * * * * *// State Code};
typedef map<string, CSTYPECSINFO; *// <=== error here
* * * * extern CSINFO cityStInfo;
* * * * extern map<string, CSTYPE>::iterator csIter;
* * * * extern CSTYPE workCS;
1. *did you #include <mapand <string>?
2. *map and string live in the std:: namespace
3. *Would you care to describe the specific error?
It's possible that his compiler does not allow the use of
incomplete types as template arguments, even in typedefs, and
'CSTYPE' is incomplete at that point...
That wasn't the case in his original code. If you'll look at
the end of the line "string csState;", you'll see the closing
brace of CSTYPE. For some reasons, something in the news very
often seems to move a line with just a }: to the end of the
preceding line. (I've always suspected Google, because that's
what I use to read news, and I'm constantly seeing this.)

Without the closing brace, of course, the code would be illegal.
Because of the incomplete type, but also because you're not
allowed to use extern in a class either (and that error requires
a dignostic).

Like Mike, I rather suspect that he's either forgotten the
include, and he's clearly fogotten the std::. Which means that
string and map are unknown symbols. To reasonably parse C++,
the compiler needs to know when a symbol names a type; use an
unknown symbol where a type is required, the compiler will
generally suppose it isn't a type (which results in a syntax
error), and the quality of the error messages go downhill from
there.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 1 '08 #7
On Oct 31, 10:43*pm, mrc2...@cox.net (Mike Copeland) wrote:
>* *I'm getting a syntax error on the "typedef" code line here. *Any
>thoughts on why? *TIA
>struct CSTYPE
>{ * * * * * * * * * * * * * * * * * * * * * * *// City/State Record
>* * * * string csKey; * * * * * * * * * * * * * *// City/State "Key"
>* * * * string csCity; * * * * * * * * * * * * * * * * * * * // City
>* * * * string csState; * * * * * * * * * * * * * * * *// State Code
>}; *<==== this was in my post, but was appended to the above line.
It's possible that his compiler does not allow the use of
incomplete types as template arguments, even in typedefs,
and 'CSTYPE' is incomplete at that point...
Yes, but please see my common above. *I _thought_ I had a
complete declaration for CSTYPE - am I wrong?
You did. Your original posting was correct in this regard, but
something in the net seems to occasionally (often, in fact) join
a line with just a "}" or a "};" with the preceding line. If
the preceding line doesn't end with a comment, it doesn't affect
the legality of the code, but it is an unusual formatting. (I
asked about this once, since I was seeing so many postings with
this unusual formatting, and thought it might be some new coding
convention I wasn't familiar with. The poster in question
assured me that the }; was on a separate line when the posting
left his machine.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 1 '08 #8

"Mike Copeland" <mr*****@cox.netwrote in message
news:MP************************@news.cox.net...
I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE // City/State Record
{
string csKey;// City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <= error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;


1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?

I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{
There is no reason I know of to use VC++ 6.0 when you can download VC++ 8.0
for free from Microsoft which is much better and up to date. See here.
http://www.microsoft.com/express/download/
I also didn't state that this is in a common .h file I'm building
(and I apologize for not mentioning that...)
Nov 1 '08 #9
Jim Langston wrote:
"Mike Copeland" <mr*****@cox.netwrote in message
news:MP************************@news.cox.net...
>>>I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE // City/State Record
{
string csKey;// City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <= error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;
1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?

I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{

There is no reason I know of to use VC++ 6.0 when you can download
VC++ 8.0 for free from Microsoft which is much better and up to
date. See here. http://www.microsoft.com/express/download/
That's VC9 even, telling us that VC6 is just ancient. Don't use it
unless someone is pulling your toenails out!
Bo Persson
Nov 1 '08 #10
James Kanze wrote:
Like Mike, I rather suspect that he's either forgotten the
include, and he's clearly fogotten the std::.
Just FYI, that was me, not Mike.
Nov 2 '08 #11
In message <MP************************@news.cox.net>, Mike Copeland
<mr*****@cox.netwrites
I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE // City/State Record
{
string csKey;// City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <= error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;


1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?

I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{
But you could tell us the *text* of the message, which might shed some
light. ;-)

Another possibility that nobody has mentioned is that you're including
some other header file which defines CSINFO or CSTYPE as a macro -
because of this, it's often a good idea to avoid using all-caps
identifiers for anything else.
I also didn't state that this is in a common .h file I'm building
(and I apologize for not mentioning that...)
--
Richard Herring
Nov 3 '08 #12
I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{

There is no reason I know of to use VC++ 6.0 when you can download VC++ 8.0
for free from Microsoft which is much better and up to date. See here.
http://www.microsoft.com/express/download/
Any way I try to get to this site, I get an error (Unable to load XML
manifest...(etc.). Is this normal, or temporary? TIA
Nov 4 '08 #13
Mike Copeland wrote:
>>I'm getting a syntax error on the "typedef" code line here. Any
thoughts on why? TIA

struct CSTYPE // City/State Record
{
string csKey;// City/State "Key"
string csCity; // City
string csState; // State Code
};
typedef map<string, CSTYPECSINFO; // <= error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;

1. did you #include <mapand <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?

I didn't state the error (C2143) because it's compiler-specififc
(VC++ 6.0) and I know that's a no-no here. 8<{{
The message is "syntax error : missing 'token1' before 'token2'",
which could be helpful in understanding your problem.
I also didn't state that this is in a common .h file I'm building
(and I apologize for not mentioning that...)
Sounds like one of the headers included before this screwed up.
Have your file preprocessed and compile the result. Check what's
just above the definition of 'CSTYPE'. (If it still /is/ 'CSTYPE'
after preprocessing.)

Schobi
Nov 4 '08 #14
Mike Copeland wrote:
[...]
>http://www.microsoft.com/express/download/

Any way I try to get to this site, I get an error (Unable to load XML
manifest...(etc.). Is this normal, or temporary? TIA
Works here (FF3).

Schobi
Nov 4 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roger Leigh | last post by:
Although I've got over most of my template-related problems, I'm having trouble when I started to use default template parameters. For template type T, I've typedef'd this as object_type and then...
4
by: Takeshi | last post by:
Hi, I wonder if anyone knows what I'm doing wrong. I'm trying to create a typedef based on a pat. Here is the code snippet: #include <utility> #include <list> #include <vector> typedef...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
2
by: Patrick Kowalzick | last post by:
Hello NG, sorry to bother again, but I am a lit surprised that I got no answer on my post (attached below). So I refined the code a little bit :-). If there is a typedefed class X inside a...
0
by: Gary | last post by:
Hi, there, I am going to use a command line parser class, which works well in VC6.0, in VC++7.1. However error message such as "C2059: syntax error :')'", and "C2061: syntax error : identifier...
6
by: Alex | last post by:
Hello people, I am getting errors from VS2003 when working with typedef'ed types. For example, assume that I have a type T, defined in a 3rd party include file based on some condition #if...
5
by: tissyrose | last post by:
Hi All, I am porting a very large application from VC++ 6.0 to VS 2005. There are many issues I am facing. One of them is I am getting an error "cannot access private typedef declared in...
2
by: linq936 | last post by:
Hi, I have a typedef like this, typedef (char* ) arrp; I want to define a type which is an array, the array has 20 elements each of which is a char*. I get compile error:
3
by: Adam Nielsen | last post by:
Hi everyone, Yet another syntax problem that's baffling me with templates. I want to instantiate a template with a single parameter as per normal, however the parameter is actually a template...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.