LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc compilation fails due to __KERNEL__ macro in mod_devicetable.h and linux/types.h (https://www.linuxquestions.org/questions/programming-9/gcc-compilation-fails-due-to-__kernel__-macro-in-mod_devicetable-h-and-linux-types-h-539906/)

ErV 03-23-2007 07:58 AM

gcc compilation fails due to __KERNEL__ macro in mod_devicetable.h and linux/types.h
 
Hello!
Currently compilation of some packages (libsvga-1.4.3, dosemu 1.2.2) fails with errors in /include/mod_devicetable.h. Error messages sounds like "295: error: storage size of 'swbit" is not known" and "error: syntax error before '__u32'". I'm using Slackware 11 with 2.6.17.13 kernel. Those errors appear when program (the one that doesn't compile) use #include <pci.h>. Upon closer examination it look like problems are caused by those lines in mod_devicetable.h:
Code:

#ifndef LINUX_MOD_DEVICETABLE_H
#define LINUX_MOD_DEVICETABLE_H

#ifdef __KERNEL__
#include <linux/types.h>
typedef unsigned long kernel_ulong_t;
#endif

compilation most likely fails because __u16 and __u32 types are declared in <linux/types.h> (actually they are defined in <linux/config.h> which is #include'd in <linux/types.h>). But __KERNEL__ macro isn't defined at compile time.

The questions are:
1)I could just comment out __KERNEL__ lines, but wouldn't that break something somewhere else? Or must I just fix every program that use <pci.h>?
2)Is this behavior "normal"? (i've rebuilt kernel recently and I'm not sure if I didn't break something somewhere).

Mara 03-25-2007 08:07 AM

Don't define __KERNEL__. It would include too many differet things you do not want. Instead, add #include <linux/types.h> to the files with #include <pci.h> (before that pci includes).


All times are GMT -5. The time now is 01:05 PM.