very strange gcc output

M

Miroslaw Osys

Hello everyone!

I am using C for almost 10 years and recently was very surprised.

Under Slackware Linux 8.1 and gcc 2.95.3 I tried to compile program
which simpler version is

----- test.c --------------
#include <termios.h>

int B0;
---------------------------

tried with
gcc -c test.c
and got
test.c:3: parse error before `0000000'

File termios.h seems not to define B0.
Could you explain me this behaviour, please?

Regards
Miroslaw Osys
 
J

Joona I Palaste

Miroslaw Osys said:
Hello everyone!
I am using C for almost 10 years and recently was very surprised.
Under Slackware Linux 8.1 and gcc 2.95.3 I tried to compile program
which simpler version is
----- test.c --------------
#include <termios.h>
int B0;
---------------------------
tried with
gcc -c test.c
and got
test.c:3: parse error before `0000000'
File termios.h seems not to define B0.
Could you explain me this behaviour, please?

termios.h does not define B0, but bits/termios.h, included indirectly
by termios.h, does. This was found by a very simple grep operation after
a preprocess-only invocation of gcc on your code.

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"C++. C++ run. Run, ++, run."
- JIPsoft
 
E

Emmanuel Delahaye

In 'comp.lang.c' said:
I am using C for almost 10 years and recently was very surprised.

Under Slackware Linux 8.1 and gcc 2.95.3 I tried to compile program
which simpler version is

----- test.c --------------
#include <termios.h>

int B0;
---------------------------

tried with
gcc -c test.c
and got
test.c:3: parse error before `0000000'

File termios.h seems not to define B0.

but some include header could, or B0 could be some gcc build-in extension,
who knows...

Try again with

gcc -c -ansi -pedantic -W -Wall -O3 test.c
Could you explain me this behaviour, please?

<termios.h> is not a standard header. Pedants say that including a non
standard header invokes an undefined behaviour. I'm close to think there are
right.

Please repost to a Linux newsgroup if your concern is <termios.h>.
 
M

Miroslaw Osys

Hi again!

Thank for responses. It is a pity I cannot use B0 identifier even as
field name...
Probably solution is to move everything related to termios.h to separate
file.

Regards
Miroslaw Osys
 
E

Emmanuel Delahaye

In 'comp.lang.c' said:
Thank for responses. It is a pity I cannot use B0 identifier even as
field name...
Probably solution is to move everything related to termios.h to separate
file.

Absolutely. It's called modular programming, and it's a Good Thing.
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top