473,378 Members | 1,619 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.

"expected unqualified-id before 'using'"

This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"
which doesn't make any sense to me - a preprocessor directive isn't
ended by a semicolon, and I must've used this little chunk of code
hundreds of times. This happened after I chopped up an unwieldy large
class into a couple of smaller classes, and this code ran just fine
before I made the changes.

The REALLY weird thing is that if I comment out the "using" statement,
the compiler jumps into the file "functexcept.h" included with Dev-C++,
and gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills
and am no comp sci wiz. I just write basic progs to help me study or
parse and modify text files.
Jul 23 '05 #1
13 141189
"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"


Probably the header file string is corrupted, likely at the end...

Use your compiler's options to get the preprocessor output to see what the
compiler is actually seeing.

Ali

Jul 23 '05 #2

"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"
which doesn't make any sense to me - a preprocessor directive isn't ended
by a semicolon, and I must've used this little chunk of code hundreds of
times. This happened after I chopped up an unwieldy large class into a
couple of smaller classes, and this code ran just fine before I made the
changes.

The REALLY weird thing is that if I comment out the "using" statement, the
compiler jumps into the file "functexcept.h" included with Dev-C++, and
gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills and
am no comp sci wiz. I just write basic progs to help me study or parse
and modify text files.


A few ideas/possibilities. Guesses, really.

One is that you've got a header file or a line in that source file before
this with incorrect line endings. If you've transported a file between
Windows and Mac, for instance, your linde endings get screwed up, and cause
weird behavior like this. If it's a line you copied and pasted from
somewhere, try deleting some of the code and re-typing it in by hand.

Another idea is that a previous compile is somehow messing with you, perhaps
because you changed source files or paths. Try a complete, clean rebuild.

I've also seen problems on some compilers if the end of a header file is a
line-comment (using //), or is a class definition without a trailing
semicolon. Check the ends of your headers and see if they're ok.

Oh, and check your compiler/build settings and paths, to be sure you haven't
selected some target/library/framework you didn't intend.

-Howard
Jul 23 '05 #3


Howard wrote:
"Squid Seven" <te*********@squidseven.com> wrote in message
news:mJ********************@adelphia.com...
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"
which doesn't make any sense to me - a preprocessor directive isn't ended
by a semicolon, and I must've used this little chunk of code hundreds of
times. This happened after I chopped up an unwieldy large class into a
couple of smaller classes, and this code ran just fine before I made the
changes.

The REALLY weird thing is that if I comment out the "using" statement, the
compiler jumps into the file "functexcept.h" included with Dev-C++, and
gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills and
am no comp sci wiz. I just write basic progs to help me study or parse
and modify text files.

A few ideas/possibilities. Guesses, really.

One is that you've got a header file or a line in that source file before
this with incorrect line endings. If you've transported a file between
Windows and Mac, for instance, your linde endings get screwed up, and cause
weird behavior like this. If it's a line you copied and pasted from
somewhere, try deleting some of the code and re-typing it in by hand.


Ali said that it might be a corrupted header file too. He suggest I use
my compiler settings to get my preprocessor output. I've spent the past
half-hour trying to figure out how to do that. How does a header file
get corrupted? I didn't transfer or move the files or in any way
interact with them except indirectly by modifying my OWN files in
Dev-C++. Urgh. I am SO FRUSTRATED!
Another idea is that a previous compile is somehow messing with you, perhaps
because you changed source files or paths. Try a complete, clean rebuild.

tried the complete rebuild, no luck
I've also seen problems on some compilers if the end of a header file is a
line-comment (using //), or is a class definition without a trailing
semicolon. Check the ends of your headers and see if they're ok.

Oh, and check your compiler/build settings and paths, to be sure you haven't
selected some target/library/framework you didn't intend.

-Howard

Jul 23 '05 #4

Ali said that it might be a corrupted header file too. He suggest I use
my compiler settings to get my preprocessor output. I've spent the past
half-hour trying to figure out how to do that. How does a header file get
corrupted? I didn't transfer or move the files or in any way interact
with them except indirectly by modifying my OWN files in Dev-C++. Urgh.
I am SO FRUSTRATED!


When all else has failed me before, I created a new project. Then, I added
in the files from the original project, one or two at a time, (commenting
out code that used files that I hadn't added back yet). Eventually, I
either found a file that, when included, screwed everything up again, or
else it miraculously worked when it was all put back together. A major pain
in the ass, but it's worked.

Perhaps more simple than this is to continue what you tried, commenting out
includes here and there until the weird error goes away. The last thing you
removed should at least give you a *hint* of where the problem might lie.

I also use the CodeWarrior IDE to load files in and make sure all the line
endings are correct. There are probably freeware tools that do that too,
though...I think CodeWarrior's expensive.

Sorry you're having so much trouble. I wish you luck in fixing it without
too much pain...

-Howard

Jul 23 '05 #5
On Thu, 14 Jul 2005 16:45:28 -0400, Squid Seven
<te*********@squidseven.com> did courageously avow:
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;
If you are specifically identifying the namespace in front of the data
type try dropping the keyword using.

std::string

I believe 'using' is used this way.

using namespace std;

That would allow you to use everything in string without needing a the
namespace every time. And this is a good thing. If you're doing a
lot of I/O do you really want to be typing std::cout and std::cin for
every time you need it?


I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"
which doesn't make any sense to me - a preprocessor directive isn't
ended by a semicolon, and I must've used this little chunk of code
hundreds of times. This happened after I chopped up an unwieldy large
class into a couple of smaller classes, and this code ran just fine
before I made the changes.

The REALLY weird thing is that if I comment out the "using" statement,
the compiler jumps into the file "functexcept.h" included with Dev-C++,
and gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills
and am no comp sci wiz. I just write basic progs to help me study or
parse and modify text files.

Ken Wilson

Amer. Dlx. Tele, Gary Moore LP, LP DC Classic w/P90s,
Jeff Beck Strat, Morgan OM Acoustic,
Rick 360/12, Std. Strat (MIM), Mesa 100 Nomad,
Mesa F-30

"Goodnight Austin, Texas, wherever you are."
Jul 23 '05 #6
OK, tell me if my logic here is good. I completely uninstalled Dev-C++
and deleted the directory it was in. Then I reinstalled it, reinstalled
all my libraries, and then tried to compile the program again, with the
same problem. This means that corrupt standard library header files,
specifically <string>, *can't* be the cause of the problem, correct? So
the problem must be in my code?

I am going to try good old-fashioned troubleshooting on my own code now
(though I can't imagine how changes there caused this problem), but I'm
hoping that someone can confirm for me that the measures taken above do
in fact confirm that the problem *is* in my own code.

Thanks much for your help guys.

Rick N. Backer wrote:
On Thu, 14 Jul 2005 16:45:28 -0400, Squid Seven
<te*********@squidseven.com> did courageously avow:

This is just bizarre. for the following snippet of code:
#include <string>
using std::string;

If you are specifically identifying the namespace in front of the data
type try dropping the keyword using.

std::string

I believe 'using' is used this way.

using namespace std;

That would allow you to use everything in string without needing a the
namespace every time. And this is a good thing. If you're doing a
lot of I/O do you really want to be typing std::cout and std::cin for
every time you need it?


I get the error message:
expected unqualified-id before "using"
expected `,' or `;' before "using"
which doesn't make any sense to me - a preprocessor directive isn't
ended by a semicolon, and I must've used this little chunk of code
hundreds of times. This happened after I chopped up an unwieldy large
class into a couple of smaller classes, and this code ran just fine
before I made the changes.

The REALLY weird thing is that if I comment out the "using" statement,
the compiler jumps into the file "functexcept.h" included with Dev-C++,
and gives me the same basic error message with regards to the following
snippet:
#include <exception_defines.h>

namespace std
{ ...
This time it informs my that the "unqualified id" lies before "namespace".

WTF!! Can anybody help me out here? I have no idea what I might have
changed that could possibly have caused this. I have basic C++ skills
and am no comp sci wiz. I just write basic progs to help me study or
parse and modify text files.


Ken Wilson

Amer. Dlx. Tele, Gary Moore LP, LP DC Classic w/P90s,
Jeff Beck Strat, Morgan OM Acoustic,
Rick 360/12, Std. Strat (MIM), Mesa 100 Nomad,
Mesa F-30

"Goodnight Austin, Texas, wherever you are."

Jul 23 '05 #7
Ian
Squid Seven wrote:
This is just bizarre. for the following snippet of code:
#include <string>
using std::string;

Are there any headers included before string? They might be broken.

Try compiling the snippet on its own.

Ian
Jul 23 '05 #8
Squid Seven wrote:
OK, tell me if my logic here is good. I completely uninstalled Dev-C++
and deleted the directory it was in. Then I reinstalled it, reinstalled
all my libraries, and then tried to compile the program again, with the
same problem. This means that corrupt standard library header files,
specifically <string>, *can't* be the cause of the problem, correct? So
the problem must be in my code?

I am going to try good old-fashioned troubleshooting on my own code now
(though I can't imagine how changes there caused this problem), but I'm
hoping that someone can confirm for me that the measures taken above do
in fact confirm that the problem *is* in my own code.


That would indeed confirm it. I mispoke earlier when I said you
couldn't use 'using' as you did but, after some looking, you were right
in its useage.

These compilers are usually very robust. If it has never caused you a
problem why would it decide to suddenly and on code you've used before.
I almost always take the blame for compiler errors and rightfully so,
except when working with MS libraries.

You stated you busted up a bunch of code. All it takes is one
semicolon out of place and it can create anything from a single
compiler error, to a fistfull of them sometimes. This is a not
uncommon occurrence if you're cutting and pasting large amouts of text
a single character is easy to lose sight ot.

Jul 23 '05 #9
Found it - a missing semicolon after the brackets of a class definition.

AAaAAHHHH!!! arghhhhhhhhhhh... !@%$@$#&^#@$%&@ (noise of forehead
striking desk repeatedly)

I still don't understand how it led to that strange little error in a
very distant area of the app, but I'm just glad that I can resume
getting things done... after four hours of banging my head against my
desk, reinstalling my development suite and libraries from scratch, and
scouring the web for irrelevant posts.

Sigh.

Thanks much for help and patience guys. I'm sure I'll be back with more
probs soon!
Jul 23 '05 #10
You got it exactly - I was thrown by the seemingly unrelated problem it
caused.

Ken Wilson wrote:
Squid Seven wrote:
OK, tell me if my logic here is good. I completely uninstalled Dev-C++
and deleted the directory it was in. Then I reinstalled it, reinstalled
all my libraries, and then tried to compile the program again, with the
same problem. This means that corrupt standard library header files,
specifically <string>, *can't* be the cause of the problem, correct? So
the problem must be in my code?

I am going to try good old-fashioned troubleshooting on my own code now
(though I can't imagine how changes there caused this problem), but I'm
hoping that someone can confirm for me that the measures taken above do
in fact confirm that the problem *is* in my own code.

That would indeed confirm it. I mispoke earlier when I said you
couldn't use 'using' as you did but, after some looking, you were right
in its useage.

These compilers are usually very robust. If it has never caused you a
problem why would it decide to suddenly and on code you've used before.
I almost always take the blame for compiler errors and rightfully so,
except when working with MS libraries.

You stated you busted up a bunch of code. All it takes is one
semicolon out of place and it can create anything from a single
compiler error, to a fistfull of them sometimes. This is a not
uncommon occurrence if you're cutting and pasting large amouts of text
a single character is easy to lose sight ot.

Jul 23 '05 #11
> I still don't understand how it led to that strange little error in a very
distant area of the app, but I'm just glad that I can resume getting
things done... after four hours of banging my head against my desk,
reinstalling my development suite and libraries from scratch, and scouring
the web for irrelevant posts.


One very important thing to remember is that sometimes compilers have real
trouble diagnosing what is wrong.

If a compiler issue an error message for line NNNN, examine the line in
question and also examine the previous lines as the error could lie there.
The compiler initially passed over the problem line because potentially it
might make syntactic sense. It wasn't until it got to line NNNN that it knew
something was wrong and complained.

And you might have to backtrack quite a bit if intervening lines amount to
comments. You are looking for the previous
declarations/defintions/statements that are not comments. See if they amount
to correct C++.

Stephen Howe


Jul 23 '05 #12
On Thu, 14 Jul 2005 20:11:49 -0400, Squid Seven
<te*********@squidseven.com> did courageously avow:
You got it exactly - I was thrown by the seemingly unrelated problem it
caused.

Ken Wilson wrote:
Squid Seven wrote:
OK, tell me if my logic here is good. I completely uninstalled Dev-C++
and deleted the directory it was in. Then I reinstalled it, reinstalled
all my libraries, and then tried to compile the program again, with the
same problem. This means that corrupt standard library header files,
specifically <string>, *can't* be the cause of the problem, correct? So
the problem must be in my code?

I am going to try good old-fashioned troubleshooting on my own code now
(though I can't imagine how changes there caused this problem), but I'm
hoping that someone can confirm for me that the measures taken above do
in fact confirm that the problem *is* in my own code.

That would indeed confirm it. I mispoke earlier when I said you
couldn't use 'using' as you did but, after some looking, you were right
in its useage.

These compilers are usually very robust. If it has never caused you a
problem why would it decide to suddenly and on code you've used before.
I almost always take the blame for compiler errors and rightfully so,
except when working with MS libraries.

You stated you busted up a bunch of code. All it takes is one
semicolon out of place and it can create anything from a single
compiler error, to a fistfull of them sometimes. This is a not
uncommon occurrence if you're cutting and pasting large amouts of text
a single character is easy to lose sight ot.


You are in good company. I would venture, except for the very
exceptional student, we've all been down this road or one similar. I
remember too long chasing down a pointer problem I thought I had
fixed. A fellow student could hear me muttering under my breath and
after watching a few minutes said "Shouldn't you recompile that before
trying to run it again?" Doh.
Ken Wilson
"Just because people don't understand you doesn't mean
you are an artist"
Jul 23 '05 #13
Ken Wilson wrote:
On Thu, 14 Jul 2005 20:11:49 -0400, Squid Seven
<te*********@squidseven.com> did courageously avow:
You got it exactly - I was thrown by the seemingly unrelated
problem it caused.
You are in good company. I would venture, except for the very
exceptional student, we've all been down this road or one similar. I
remember too long chasing down a pointer problem I thought I had
fixed. A fellow student could hear me muttering under my breath and
after watching a few minutes said "Shouldn't you recompile that before
trying to run it again?" Doh.

I just did something like that recently. Trying to debug a program,
making changes, now the debugger seems off. Tried adding print
statements, those didn't work, frustrating. Then somebody points out
I'm rebuilding a different project than the one I'm debugging. As it
was embedded program loaded onto a target board, it didn't detect that
the target image wasn't up-to-date. Grrrrrrrrr.

Brian
Jul 23 '05 #14

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

Similar topics

4
by: Grzegorz Dostatni | last post by:
Good morning. I've got a Tkinter problem: File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 2310, in selection_present return self.tk.getboolean( TclError: expected boolean value but got "" ...
1
by: Phil Powell | last post by:
Here is the function ArraySearch: '-------------------------------------------------------------------------------------- 'ArraySearch will return an integer value indicating the first...
3
by: NeilH | last post by:
Hello All I was wondering if someone could offer a rather inexperienced person some advice. Im trying to get my asp page to look at an access data I created the following query in access...
7
by: Aaron G via AccessMonster.com | last post by:
Wanted to share a solution to something which I didn't find on the net: EVERY form in my Microsoft Access 2002 database gave an error any time any code was to be called: form OnOpen, button...
2
by: Matt Suther | last post by:
Does it matter if I use "The C Programming Language" with Windows XP? I've gotten some of the scripts from it to work, but some don't. Could this be an issue with Windows? Or an issue with the...
3
by: moi | last post by:
Hello, When user write a decimal number in a textbox with the numeric pad, he hits the "." button but in FRANCE, we use the ",". How to change the "." in the textbox with a "," ? Example : user...
2
by: P | last post by:
Hi all, I'm trying to run the following code taken from http://blogs.ittoolbox.com/database/technology/archives/006045.asp# select substr(tablespace_name,1,30) as "Tablespace Name", case...
1
by: nagaraj | last post by:
In Dev C++, we tried to compile a application, but it will throw some peculiar error. please find it below "path/main.cpp expected `]' before ';' token" and the source code is "DWORD rtec_Stack...
9
by: Rohit | last post by:
I am trying to initialize an array whose initializers depend on value of Enums. I take enum and then decide the initializer value, so that even if enum value changes because of addition to list...
5
by: Phacer | last post by:
When trying to compile I get this /main.c:30: error: expected identifier or '(' before '{' token ../main.c:31: error: expected identifier or '(' before 'if' make: *** Error 1 SDL_SysWMinfo...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.