LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-27-2009, 12:09 PM   #1
ddeeks
LQ Newbie
 
Registered: May 2009
Posts: 11

Rep: Reputation: 0
Thumbs up static struct pci_driver unknown field 'name' "has initializer but incomplete type"


I am writing a PCI device driver in gnu gcc

The includes are:


#include <linux/kernel.h>
#include <pci/config.h>
#include "/usr/src/kernels/2.6.27.21-170.2.56.fc10.i686/include/linux/pci.h"
#include <stdio.h>
#include <stdlib.h>

//#include <unistd.h>
//#include <linux/types.h>
#include <sys/types.h>
//#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>




The

static struct pci_device_id
NHI_15504_idtable [] = {
{ vendor : NHI_15504_VENDOR_ID,
device : NHI_15504_DEVICE_ID,
subvendor : PCI_ANY_ID,
subdevice : PCI_ANY_ID,
class : 0,
class_mask : 0,
driver_data :0,
},
{0,},
};


compiles cleanly. I have stubbed out the probe callback function.
The problem arises in the declaration of the


static struct pci_driver NHI_15504_driver = {
.name = "NHI_15504",
.id_table = NHI_15504_idtable,
.probe = &NHI_15504_probe,
.remove = NULL,

};

I get the following errors


make all
Building file: ../NHI_15504.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"NHI_15504.d" -MT"NHI_15504.d" -o"NHI_15504.o" "../NHI_15504.c"
In file included from ../NHI_15504.c:46:
/usr/src/kernels/2.6.27.21-170.2.56.fc10.i686/include/linux/mod_devicetable.h:310: error: ‘BITS_PER_LONG’ undeclared here (not in a function)

../NHI_15504.c:91: error: variable ‘NHI_15504_driver’ has initializer but incomplete type
../NHI_15504.c:92: error: unknown field ‘name’ specified in initializer
../NHI_15504.c:92: warning: excess elements in struct initializer
../NHI_15504.c:92: warning: (near initialization for ‘NHI_15504_driver’)
../NHI_15504.c:93: error: unknown field specified in initializer
../NHI_15504.c:93: warning: excess elements in struct initializer
../NHI_15504.c:93: warning: (near initialization for ‘NHI_15504_driver’)
../NHI_15504.c:94: error: unknown field ‘probe’ specified in initializer
../NHI_15504.c:94: warning: excess elements in struct initializer
../NHI_15504.c:94: warning: (near initialization for ‘NHI_15504_driver’)
../NHI_15504.c:95: error: unknown field ‘remove’ specified in initializer
../NHI_15504.c:95: warning: excess elements in struct initializer
../NHI_15504.c:95: warning: (near initialization for ‘NHI_15504_driver’)
../NHI_15504.c: In function ‘__init’:
../NHI_15504.c:115: warning: implicit declaration of function ‘pci_register_driver’
make: *** [NHI_15504.o] Error 1

Questions:
1) The Error

mod_devicetable.h:310: error: ‘BITS_PER_LONG’ undeclared here (not in a function)

The BITS_PER_LONG are define in file2alias.c as as result of

#if KERNEL_ELFCLASS == ELFCLASS32

(a) Where should KERNEL_ELFCLASS be #defined?
(b) Should it not be define already??

2) The Error

../NHI_15504.c:91: error: variable ‘NHI_15504_driver’ has initializer but incomplete type

(a) What am I missing in this struct declaration?
(b) Why are the fields 'name', ‘id_table’ 'probe" 'remove' unknown fields in this struct?
 
  


Reply

Tags
field, name, unknown



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
error: variable ‘fops’ has initializer but incomplete type rajkumar_halle Programming 1 08-24-2008 08:57 AM
error: variable ‘scull_fops’ has initializer but incomplete type rajkumar_halle Programming 1 08-19-2008 12:51 AM
"array type has incomplete element type" compiling 2.4.32 kernel Akabaka Linux - General 1 01-08-2006 12:48 PM
C error "dereferencing pointer to incomplete type" lucs Slackware 6 02-21-2005 09:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration