Linux header files giving syntax error-Collection of common programming errors

On trying to compile a program using gcc I get the following error.

In file included from /usr/include/unistd.h:218:0, from fcfssched.c:3: /usr/include/x86_64-linux-gnu/bits/types.h:31:1:

error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘typedef’

The error appears to be in the header file /bits/types.h

The second error is (probably) a result of the first.

In file included from /usr/include/stdlib.h:320:0, from fcfssched.c:5: /usr/include/x86_64-linux-gnu/sys/types.h:34:1:

error: unknown type name ‘__u_char’

How do I solve this ?

The header file appears to be fine. I just updated the headers using the libc6-dev package. I am using Ubuntu 12.04 x86 with Kernel 3.2.0-36-generic

  1. This kind of error generally occurs in case of syntax error around the include directive in the user code.

    You should have a look in your sources if there is not a missing ; or } near the include which falls by including /bits/types.h (following the inclusion tree).

  2. This error generally comes when you missed the (;) or (}) in the coding line. Kindly check the each line of code written by you.

    The best way to get the issue resolve is to start check the code reverse line by line from the error line received. Don’t check the standard files included in the project. The error comes from the your coded file.

Originally posted 2013-11-09 23:32:12.