How to find out the weird character in the code

1

1230987za

Hi,

The GCC compiler complains my code:

error: expected expression before ‘,’ token

I go to that line and do not see such token. I am using vim.

Is there a way to find out this?
 
1

1230987za

It's actually a comma with some pointless Unicode quotes around it.

If you set your locale to something basic (like "C") then gcc may
refrain from using such pointless characters. This may involve
setting an environment variable such as "LANG" to "C".

-- RIchard

Thanks for the quick reply, but the GCC and the program build is under
some machines out of my control, I can only modify the source code.
The problem is I can not see such character in my editor, vim. I tried
deleted the comma and re-typed it, but it did not help.

Any idea?
 
R

Richard Tobin

The GCC compiler complains my code:

error: expected expression before ‘,’ token

I go to that line and do not see such token. I am using vim.

It's actually a comma with some pointless Unicode quotes around it.

If you set your locale to something basic (like "C") then gcc may
refrain from using such pointless characters. This may involve
setting an environment variable such as "LANG" to "C".

-- RIchard
 
J

jameskuyper

Thanks for the quick reply, but the GCC and the program build is under
some machines out of my control, I can only modify the source code.
The problem is I can not see such character in my editor, vim. I tried
deleted the comma and re-typed it, but it did not help.

The token it's referring to IS the comma token. If you were able to
delete a comma, that means you found (and deleted and replaced) the
token. Now the thing you need to do is figure out what you've got
before the comma token, which the compiler is complaining about. It
said it's expecting an expression before the comma. That would be true
whether the comma was an actual comma operator, or the seperator in a
function call or an initializer list, so that doesn't really tell us
much.

The message implies that one solution would be to insert an
appropriate expression before the comma, but in my experience that's
unlikely to be the correct solution.. The real problem could be that
you put a comma in a place where you shouldn't have, or any number of
other possibilities Unfortunately, there's not much advice we can give
you until you post the actual source code that is producing this error
message.
 
K

Keith Thompson

The GCC compiler complains my code:

error: expected expression before ‘,’ token

I go to that line and do not see such token. I am using vim.

Is there a way to find out this?

The message it's trying to display is:

error: expected expression before ',' token

The compiler is running in an environment where it's been told it can
use the UTF-8 encoding for Unicode characters. UTF-8 is identical to
ASCII for many common characters, but for characters that can't be
represented in 7-bit ASCII it uses a multi-byte encoding. In this
case, it's printing the encoding for an opening single quote, followed
by a comma, followed by the encoding for a closing single quote.
(ASCII has the apostrophe and backtick characters, but not opening and
closing single quotes).

If you can control the locale under which gcc runs, you can get it to
use ASCII apostrophes, but you've indicated that that's not feasible.

If the error message is saved to a log file, and if you have the
"iconv" command on your system, you might be able to translate it
to something legible.

Or you can just ignore the funny characters and realize that gcc is
simply referring to a ',' (comma) token. You almost certainly have a
comma character on the specified line, and a syntax error on or just
before that line.

Syntax error messages can be obscure; typically the compiler tries to
guess what *should* be there, but C's syntax is sufficiently "dense"
that its guess is very often wrong. With some practice, just knowing
that there's a syntax error should be enough to let you find the
problem. If you can't figure it out, post your source (copy-and-paste
it, don't re-type it) and we can help.
 
J

John Bode

Hi,

The GCC compiler complains my code:

error: expected expression before ‘,’ token

I go to that line and do not see such token. I am using vim.

Is there a way to find out this?

The compiler is complaining that it found a comma where it was
expecting an expression (something along the lines of writing a
= ,b). Without seeing the code in question, it's hard to diagnose
what your problem is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top