It might be a question of ordering. Do you include linux/types.h before
the first reference of any type defined in there (e.g. resource_size_t
must be defined before the first usage; usage includes also function
prototypes in other header files)? Thus, it might help to include
linux/types.h as first header file.
I found out that I was actually missing a required #define. In order to get types.h to register types such as u32, I need to include the following in my code:
#define __KERNEL__
After which I moved on to the next set of errors.
Now I'm stuck on an issue with posix_types.h. The file sysfs.h requires a type 'mode_t' which is of type '__kernel_mode_t' in types.h. This is defined in several places, but the main one appears to be asm/posix_types.h (where asm is linked to asm-microblaze).
If you #include this file, I still get errors about mode_t not being defined:
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:22: error: parse error before "mode_t"
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:22: warning: no semicolon at end of struct or union
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:55: error: field `attr' has incomplete type
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:58: error: parse error before "ssize_t"
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:58: warning: no semicolon at end of struct or union
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:59: error: parse error before '*' token
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:59: error: parse error before "loff_t"
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:59: warning: type defaults to `int' in declaration of `ssize_t'
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:59: error: `ssize_t' declared as function returning a function
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:59: warning: data definition has no type or storage class
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:62: error: parse error before '}' token
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:65: error: parse error before "ssize_t"
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:65: warning: no semicolon at end of struct or union
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:66: error: parse error before '*' token
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:66: warning: type defaults to `int' in declaration of `ssize_t'
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:66: error: `ssize_t' declared as function returning a function
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:66: warning: data definition has no type or storage class
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:67: error: parse error before '}' token
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/linux/sysfs.h:162: error: parse error before "mode_t"
I've #included linux/posix_types.h, which #includes asm/posix_types.h. Both contain #ifndefs that prohibit the header file commands from being run more than once by other files. If I comment out the following in asm/posix_types.h
#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H
#idefine _ASM_MICROBLAZE_POSIX_TYPES_H
I get errors saying:
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/asm/posix_types.h:23: error: conflicting types for '__kernel_ipc_pid_t'
/home/mstanisz/petalinux-svn/tools/linux-i386/microblaze-uclinux-tools/bin/../lib/gcc/microblaze-uclinux/3.4.1/../../../../microblaze-uclinux/include/bits/kernel_types.h:27: error: previous declaration of '__kernel_ipc_pid_t' was here
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/asm/posix_types.h:26: error: conflicting types for '__kernel_size_t'
/home/mstanisz/petalinux-svn/tools/linux-i386/microblaze-uclinux-tools/bin/../lib/gcc/microblaze-uclinux/3.4.1/../../../../microblaze-uclinux/include/bits/kernel_types.h:30: error: previous declaration of '__kernel_size_t' was here
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/asm/posix_types.h:27: error: conflicting types for '__kernel_ssize_t'
/home/mstanisz/petalinux-svn/tools/linux-i386/microblaze-uclinux-tools/bin/../lib/gcc/microblaze-uclinux/3.4.1/../../../../microblaze-uclinux/include/bits/kernel_types.h:31: error: previous declaration of '__kernel_ssize_t' was here
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/asm/posix_types.h:43: error: conflicting types for '__kernel_old_dev_t'
/home/mstanisz/petalinux-svn/tools/linux-i386/microblaze-uclinux-tools/bin/../lib/gcc/microblaze-uclinux/3.4.1/../../../../microblaze-uclinux/include/bits/kernel_types.h:45: error: previous declaration of '__kernel_old_dev_t' was here
/home/mstanisz/petalinux-svn/software/petalinux-dist/include/asm/posix_types.h:55: error: conflicting types for '__kernel_fsid_t'
/home/mstanisz/petalinux-svn/tools/linux-i386/microblaze-uclinux-tools/bin/../lib/gcc/microblaze-uclinux/3.4.1/../../../../microblaze-uclinux/include/bits/kernel_types.h:53: error: previous declaration of '__kernel_fsid_t' was here
So, it would appear other types are defined in two places while __kernel_mode_t is not.
As a side note, I'm doing all my development on this C source file in the user-apps directory, not the kernel directory. Moving the source files over to the kernel source then compiling had no effect.
Any suggestions? I'm glad to see that people are interested, I really hope to get this working. Thanks.
Matt