PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : gcc-bug?



nobody0
13-02-2004, 15:15
Beim folgenden Minimal-Modul beschwert sich der gcc wenn ich eine union-Komponente mit Namen "si_value" verwende. aber es ist problemlos mit "sivalue".

Das ist eindeutig ein Bug der zeigt, dass der gcc mehrere Namespaces (den vom Programm u. den gcc-internen) vermischt, oder sehe ich das falsch?
:confused:



/*


bsp0.c: Demonstates a gcc bug: si_value and ui_value are used from the gcc and cannot be used as variables (see si_value below).


compile with
gcc -O6 -Wall -DLINUX -I /lib/modules/`uname -r`/build/include -c bsp0.c


*/



#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif

#include <linux/module.h>
#include <linux/kernel.h> /* Fuer z.B. printk */
#include <linux/sched.h> /* Fuer z.B. free_irq */
#include <linux/init.h> /* Fuer z.B. __init */
#include <linux/signal.h>
#include <linux/errno.h> /* Fuer z.B. EINVAL */
#include <linux/mm.h> /* Fuer z.B. GFP_xxx-Makros */
#include <linux/poll.h>
#include <linux/miscdevice.h>
#include <linux/random.h>
#include <linux/delay.h> /* Fuer z.B. udelay */
#include <linux/ioport.h> /* Fuer z.B. request_mem_region */
#include <linux/smbno.h> /* Fuer z.B. SUCCESS */
#include <linux/major.h> /* Fuer */
#include <linux/fs.h> /* Fuer z.B. struct file_operation */
#include <linux/types.h> /* u16, u32 and such */
// #include <linux/slab.h> /* Fuer z.B. kmalloc, kfree */





/* Lokale Funtionen */
static loff_t bsp0_llseek (struct file *filp, loff_t ppos, int origin);
static ssize_t bsp0_read (struct file *filp, char *buf, size_t count, loff_t * ppos);
static ssize_t bsp0_write (struct file *filp, const char *buf, size_t count, loff_t * ppos);
static int bsp0_ioctl (struct inode *inode, struct file *filp, unsigned int iocmd, unsigned long ioarg);
static int bsp0_open (struct inode *inode, struct file *filp);
static int bsp0_close (struct inode *inode, struct file *filp);





// macro for resetting the grey decoder variables (above) in a stationary position




struct file_operations bsp0_fops = {
llseek:bsp0_llseek,
read:bsp0_read,
write:bsp0_write,
open:bsp0_open,
release:bsp0_close,
ioctl:bsp0_ioctl,
};




/*
* close access to the bsp0
*/
static int
bsp0_close (struct inode *inode, struct file *filp)
{


MOD_DEC_USE_COUNT;

return (0);
}



void
cleanup_module (void)
{


return;
}



// init static int __init
int
init_module (void)
{
return 0;
}


// read access from user space
static ssize_t
bsp0_read (struct file *filp, char *buf, size_t count, loff_t * ppos)
{
// unsigned long flags;


union u_tag
{
s32 si_value; // caution with the member name si_value: gcc warns with no semicolon at end of struct or union
u32 ui_value;
} *u_value =
{
(void *) buf}; // correct cast

return (count);
} /* ..end of bsp0_read. */


// write: >=1 int: reset grey decoder, >=2: set position to zero
static ssize_t
bsp0_write (struct file *filp, const char *buf, size_t count, loff_t * ppos)
{

return (0);
} /* ..end of bsp0_write. */


static loff_t
bsp0_llseek (struct file *filp, loff_t ppos, int origin)
{

return (-EINVAL); /* Fehler -> zurueck. */
} /* ..end of bsp0_lseek. */


static int
bsp0_ioctl (struct inode *inode, struct file *filp, unsigned int iocmd, unsigned long ioarg)
{

return (-EINVAL); /* Fehler -> zurueck. */
} /* ..end of bsp0_ioctl. */


static int
bsp0_open (struct inode *inode, struct file *filp)
{

return (0);
} /* ..end of bsp0_open. */

nobody0
23-02-2004, 23:48
Anscheinend ist das kein echter bug, denn mittels etags zeigt mir emacs dass si_value in linux32.h definiert wird und das wird wohl über andere header-files eingebunden.

In dem Fall stimmt aber die Fehlermeldung nicht ganz; da müsste sowas wie redefinition error kommen.