(Q) Which header files?

(Q) Which header files?

Post by Timothy Murp » Mon, 09 Jun 2003 12:09:38



I'm trying to compile afpfs --
which doesn't appear to have been touched since linux-2.0 --
under a current 2.4 kernel.

I'm wondering which headers should be used.
Should one use the headers in /usr/src/linux/include/linux/
where possible?

I'm finding it quite difficult to deal with C source files
which require both <sys/types.h> and <linux/types.h> .
If one puts <sys/types.h> first then <features.h> is called,
and this has # define __KERNEL_STRICT_NAMES
which has the effect of cutting off some required typedefs.

On the other hand if one puts <linux/types.h> first
then many typedef's are duplicated, causing errors.

Here's the kind of trick I'm driven to:
=========================================
#include <linux/types.h>
# define __dev_t_defined
# define __mode_t_defined
# define __nlink_t_defined
#include <sys/types.h>
=========================================

I'm sure there must be a better way of doing this.
Any suggestions or advice gratefully received.

Incidentally, is there any way of "undefining" a typedef?

Is there any advice anywhere on this kind of thing.

--
Timothy Murphy  

tel: 086-233 6090
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland

 
 
 

(Q) Which header files?

Post by Kevin Easto » Mon, 09 Jun 2003 17:38:06


[...]

I don't know the answer to the rest of your problem, but...

Quote:> Incidentally, is there any way of "undefining" a typedef?

No.  typedef is handled as a storage class - typedef names are like
object names (so you can't undefine a typedef for the same reason you
can't undefine a variable).

        - Kevin.

 
 
 

(Q) Which header files?

Post by Jens.Toerr.. » Mon, 09 Jun 2003 22:05:03



> I'm trying to compile afpfs --
> which doesn't appear to have been touched since linux-2.0 --
> under a current 2.4 kernel.
> I'm wondering which headers should be used.
> Should one use the headers in /usr/src/linux/include/linux/
> where possible?

Depends on what afpfs is. If it's a kernel module you should
include the kernel headers from /usr/src/linux/include
(but *not* via /usr/include/linux but via
/lib/modules/`uname -r`/build/include, where the `uname -r`
gets expanded to the name of the currently running kernel).
If it's a userland application you usually never should use
these kernel header files.

Quote:> I'm finding it quite difficult to deal with C source files
> which require both <sys/types.h> and <linux/types.h> .
> If one puts <sys/types.h> first then <features.h> is called,
> and this has # define __KERNEL_STRICT_NAMES
> which has the effect of cutting off some required typedefs.

Mixing header files from /usr/include/sys and kernel header
files is usually a sure sign that there's something heavily
broken. And stuff from /usr/include/linux should usually
never be used from normal userland applications or modules.
And there were changes from 2.0 to 2.4, in 2.0 times
/usr/include/linux was supposed to be a symbolic link to
/usr/src/linux/include/linux, but that's not the case
anymore. Nowadays you get there via
/lib/modules/`uname -r`/build/include/linux.

                                Regards, Jens
      _  _____  _____

  _  | |  | |    | |
 | |_| |  | |    | |          http://www.physik.fu-berlin.de/~toerring
  \___/ens|_|homs|_|oerring

 
 
 

1. glibc header files or kernel header files?

I have succesfully installed glibc 2.0.3 on my system. Just recently I have
tried to compile kernel 2.0.30 with it. I also added the pc speaker sound
driver and the newer version of ppp. The kernel compiles fine without the
pc speaker and ppp drivers but with it it fails. The cause appears to be that
the header files installed in /usr/include/sys by glibc conflict with the
header files in linu source tree. Which headers should I use.I tried to
use just the headers from glibc (I copyed all the sys/foo.h over the linux
header files) and the kernel wouldn't compile at all. So which should I use.
Thank you for yur time.

                                                James Simmons
--

2. application contest

3. #ifndef/#ifdef problems in my header file (conditional header inclusion)

4. samba won't start at boot

5. Headers, Headers, whos got the Headers

6. 2.5.31 devfs consoles

7. 3 Qs - lock file, sound, mounting CD-ROM

8. cronjobs fail for non-root users

9. 2 Qs: modem connect speed indication, and mounting file system over modem link

10. Apache don't the HEADER file and README file...

11. header files needed if object files are available in C++ ?

12. linux header files (include files)

13. How to replace file header with the content of another file