Can anyone help : ERROR 296 - HP UX

This is a discussion on Can anyone help : ERROR 296 - HP UX ; Error 298: "test.c", line 6 # In ANSI C bitfields must be one of 'int', 'signed int', or 'unsigned int' type. u_char field1 :4; ------- #include #include #include struct { u_char field1 :4; }full_of_fields; int main() { int *ptr; ptr=malloc(10); ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Can anyone help : ERROR 296

  1. Can anyone help : ERROR 296

    Error 298: "test.c", line 6 # In ANSI C bitfields must be one of 'int',
    'signed int', or 'unsigned int' type.
    u_char field1 :4;
    -------

    #include
    #include
    #include

    struct {
    u_char field1 :4;
    }full_of_fields;

    int main()
    {
    int *ptr;
    ptr=malloc(10);
    printf ("Jai Shiv\n");
    }


  2. Re: Can anyone help : ERROR 296

    ramesh.sarda@gmail.com writes:

    > Error 298: "test.c", line 6 # In ANSI C bitfields must be one of 'int',
    > 'signed int', or 'unsigned int' type.
    > u_char field1 :4;


    Did you have a question, or are you simply entertaining us with
    your buggy code? Please read this:
    http://www.catb.org/~esr/faqs/smart-questions.html

    > struct {
    > u_char field1 :4;
    > }full_of_fields;


    Make that (just like compiler told you to):

    struct {
    unsigned int field1 :4;
    } full_of_fields;

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: Can anyone help : ERROR 296

    In article <1127376984.885301.315410@z14g2000cwz.googlegroups. com> you wrote:
    : Error 298: "test.c", line 6 # In ANSI C bitfields must be one of 'int',
    : 'signed int', or 'unsigned int' type.
    : u_char field1 :4;

    What compiler version (-V) are you using?
    I can't get that error unless +We298 is used.

    Only obsolete A.03.30 and A.03.31 will give that error by default.
    And the Release Notes for aC++ A.03.30 state:
    o Early Support for ANSI C compiler
    Not all features are enabled in this release. The following is a
    list of current limitations. Some code that is a warning in C is
    a fatal error in aC++.
    (Unfortunately Error 298 wasn't listed.)

    In other words, if you are on PA, you should be using cc for the ANSI C
    compiler, not aCC -Ae.
    On IPF, it doesn't much matter since they are the same.

+ Reply to Thread