Topic: enum and bit fields...
Author: karim@info.polymtl.ca (Aktouf Karim)
Date: Fri, 13 Aug 1993 13:28:04 GMT Raw View
Hello there!
Why does the Borland C 3.1 compiler say that enum is not allowed in bit fields,
as in this example:
typedef enum _TypeCell {NEITHER, SPAN, FRONTIER} TypeCell;
typedef struct _Cell
{
TypeCell Kind:2;
int x:1, y:1;
}Cell;
The compiler says that Kind should be of type int or unsigned... But, enum is
of type int!!!
The Unix cc compiler compiled the code with no errors, and the BCC 3.1 did so
in C++ mode. But, if I try to compile it in standard C, an error is generated...
Is it a BC 3.1 bug?
Thanks in advance!
Karim
--
| Irikar Le Maure | Ecole : karim@info.polymtl.ca |
| Je pense, donc je nuis | Boulot: karim@alex.qc.ca |
|----------------------------------------------------------|
| Ecole Polytechnique de Montreal - Alex Informatique Inc. |
.. il n'entrerait dans la saintete, aux yeux de Dieu, que
s'il rentrait dans l'infamie aux yeux des hommes.
Victor Hugo, "Les miserables".
Author: kanze@us-es.sel.de (James Kanze)
Date: 13 Aug 93 19:21:13 Raw View
In article <1993Aug13.132804.29374@vlsi.polymtl.ca>
karim@info.polymtl.ca (Aktouf Karim) writes:
|> Why does the Borland C 3.1 compiler say that enum is not allowed in bit fields,
|> as in this example:
|> typedef enum _TypeCell {NEITHER, SPAN, FRONTIER} TypeCell;
|> typedef struct _Cell
|> {
|> TypeCell Kind:2;
|> int x:1, y:1;
|> }Cell;
|> The compiler says that Kind should be of type int or unsigned... But, enum is
|> of type int!!!
|> The Unix cc compiler compiled the code with no errors, and the BCC 3.1 did so
|> in C++ mode. But, if I try to compile it in standard C, an error is generated...
|> Is it a BC 3.1 bug?
Haven't you got the BC compiler messages mixed up. This is definitely
an error in C++; enum's aren't int's. (But they were in C, though.)
--
James Kanze email: kanze@us-es.sel.de
GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung