 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sat Mar 10, 2007 6:49 pm Post subject: Help with some code... compiler errors |
|
|
hi,
Using CC65 compiler..
code:
while(1) {
if ( url_ready_flag == 0 ) {
*(url_host) = 0;
url_ready(url_host, url_page);
if (url_host != "") {
resolv_query(url_host);
}
}
I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
if (url_ready_flag == 0) {
line generates errors:
) expected
expression expected
statement has no effect
; expected
anyone know whats going on ?
aiiadict AT gmail.com
putmeouttayourmisery on yahoo messenger
Rich
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Chinese Developer Guest
|
Posted: Tue Mar 13, 2007 3:02 am Post subject: Re: Help with some code... compiler errors |
|
|
about url_host
I think it is a pointer.
Coz code "*(url_host) = 0; " indicates it's a pointer.
So statment "if (url_host != "") { "
is wrong.
url_host is a pointer which cannot be compared with "".
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Hans-Bernhard Brφker Guest
|
Posted: Tue Mar 13, 2007 3:02 am Post subject: Re: Help with some code... compiler errors |
|
|
aiiadict (AT) gmail (DOT) com wrote:
Well, no that's not "code", that's just an almost completely meaningless
snippet ripped out of its context.
| Quote: | if (url_ready_flag == 0) {
line generates errors:
) expected
expression expected
statement has no effect
; expected
anyone know whats going on ?
|
No. That's because the actual problem is almost certainly outside the
piece of code you quoted. There are errors in the snippet itself, too,
but not the errors you quote, in the line you say they're referring to.
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Barry Schwarz Guest
|
Posted: Tue Mar 13, 2007 3:02 am Post subject: Re: Help with some code... compiler errors |
|
|
On 10 Mar 2007 12:49:01 GMT, aiiadict (AT) gmail (DOT) com wrote:
| Quote: | hi,
Using CC65 compiler..
code:
|
Are you sure this is C and not C++?
| Quote: |
while(1) {
if ( url_ready_flag == 0 ) {
*(url_host) = 0;
|
This statement (along with the 2nd one following) strongly implies
that url_host is either an array of character or a pointer to char
that points to an area of memory you can modify. In particular, it
does not point to a string literal.
| Quote: | url_ready(url_host, url_page);
if (url_host != "") {
|
In C, this asks if the address that the expression url_host resolves
to is different than the address of the string literal "". Since we
have already established that url_host does not point to any string
literal, the if must always be true.
I'm not sure but in C++ I think this might be a string comparison.
| Quote: | resolv_query(url_host);
}
}
|
You have 3 "{" but only 2 "}".
Did you cut and paste the code or retype it? If the latter, do the
former.
| Quote: |
I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
if (url_ready_flag == 0) {
|
Show the complete definition of url_ready_flag (is it really a scalar
object) and several lines of code preceding the if (the compiler
sometimes doesn't realize there is a problem until much later).
| Quote: |
line generates errors:
) expected
expression expected
statement has no effect
; expected
|
Is the character between the "if" and the "(" truly a space and not
some unprintable character. The error messages imply the compiler
thinks this is a function call and wants to see
ifx(url_ready_flag) == 0;
| Quote: |
anyone know whats going on ?
aiiadict AT gmail.com
putmeouttayourmisery on yahoo messenger
Rich
|
Remove del for email
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Keith Thompson Guest
|
Posted: Tue Mar 13, 2007 3:02 am Post subject: Re: Help with some code... compiler errors |
|
|
aiiadict (AT) gmail (DOT) com writes:
| Quote: | Using CC65 compiler..
|
A Google search indicates that "cc65" is a freeware compiler for 6502
based systems. If your problem is specific to cc65, you're asking in
the wrong place. Since it's a syntax error, though, it *probably*
doesn't matter which compiler you're using.
| Quote: | code:
while(1) {
if ( url_ready_flag == 0 ) {
*(url_host) = 0;
url_ready(url_host, url_page);
if (url_host != "") {
resolv_query(url_host);
}
}
I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
if (url_ready_flag == 0) {
line generates errors:
) expected
expression expected
statement has no effect
; expected
anyone know whats going on ?
|
Not a clue. Either there's an error somewhere above the code you
posted, or url_ready_flag is defined in such a way as to create a
syntax error on that line, or the code you compiled isn't exactly the
same as the code you posted. More generally, you haven't shown us
what's causing the error, and we can't guess.
All the url_whatever stuff is undoubtedly specific to some
non-standard library you're using.
If you'll post a small complete program that exhibits the problem,
along with the exact error message, we might be able to help. Be sure
to copy-and-paste both the code and the error message; don't
paraphrase or re-type ether one.
--
Keith Thompson (The_Other_Keith) kst-u (AT) mib (DOT) org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Ulrich Eckhardt Guest
|
Posted: Tue Mar 13, 2007 3:02 am Post subject: Re: Help with some code... compiler errors |
|
|
aiiadict (AT) gmail (DOT) com wrote:
| Quote: | while(1) {
if ( url_ready_flag == 0 ) {
*(url_host) = 0;
url_ready(url_host, url_page);
if (url_host != "") {
resolv_query(url_host);
}
}
|
Some things here:
1. Your indentation is inconsistent. Clean up your code before posting and
reduce it to a minimal example.
2. Your snippet is incomplete. I see an unmatched '{'.
3. 'url_host != ""' is probably not going to do what you think it does,
unless you are programming in C++ in which case this would be the wrong
newsgroup.
4. Using brackets around 'url_host' is useless. You use brackets only to
group things where operator precedence would group them differently, but a
single item can't be grouped differently.
| Quote: | I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
|
I already noted several points above, but most of all the code is lacking
context.
| Quote: | if (url_ready_flag == 0) {
line generates errors:
) expected
expression expected
statement has no effect
; expected
|
Impossible to tell without context.
Uli
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
Jack Klein Guest
|
Posted: Tue Mar 13, 2007 3:03 am Post subject: Re: Help with some code... compiler errors |
|
|
On 10 Mar 2007 12:49:01 GMT, aiiadict (AT) gmail (DOT) com wrote in
comp.lang.c.moderated:
| Quote: | hi,
Using CC65 compiler..
|
If the specific compiler is relevant, the question would not belong
here, but in a compiler specific group, if there is one.
| Quote: | code:
while(1) {
if ( url_ready_flag == 0 ) {
*(url_host) = 0;
url_ready(url_host, url_page);
if (url_host != "") {
resolv_query(url_host);
}
}
I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
if (url_ready_flag == 0) {
line generates errors:
) expected
expression expected
statement has no effect
; expected
anyone know whats going on ?
|
I don't think anyone here is going to be able to help you, you haven't
really provided enough information.
At the very least we would need to see the definition of
"url_ready_flag". If there is a definition or declaration of it in
scope, and it if is a simple scalar type, there is nothing wrong with
that line of code.
Without that information, there isn't much to go on.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
David Given Guest
|
Posted: Tue Mar 13, 2007 3:03 am Post subject: Re: Help with some code... compiler errors |
|
|
aiiadict (AT) gmail (DOT) com wrote:
[...]
| Quote: | I'm NOT a C language programmer, but I'm learning because the project
interests me (I'm doing the assembly language)
what is wrong with the above code?
|
A brief glance doesn't indicate any gross errors, which means the problem is
probably elsewhere --- I really need more context. I'd suggest looking to see
if url_ready_flag is declared. Also, make sure that the code snippet is
actually inside a function.
Also, this line:
if (url_host != "") {
....is deeply dubious; it doesn't do what you think it does. It *looks* like
it's checking to see if url_host is an empty string. What it's *actually*
doing is checking to see if url_host is pointing at *an* empty string. If it's
pointing at a *different* empty string, the test will fail, probably
erroneously. You want to do this:
if (strcmp(url_host, "") == 0) {
....instead; strcmp() compares the contents of strings. (Or, as a shortcut, you
can do:
if (url_host[0] != '\0') {
....which checks the first character of the string to see if it's \0, which
terminates a string.)
--
βββ ο½ο½οΌ ο½ο½ο½ο½ο½ο½ο½οΌο½ο½ο½ βββ http://www.cowlark.com βββββββββββββββββββ
β "Wizards get cranky, / Dark days dawn, / Riders smell manky, / The road
β goes on. / Omens are lowering, / Elves go West; / The Shire needs
β scouring, / You may as well quest." - John M. Ford
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|