This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix compilation error in i2c.cxx


Ian Campbell wrote:
Hi all,

CVS 2005-06-16 had this problem, and I've not seen anything on this list
which suggests i2c has changed.

make[1]: Entering directory `/home/icampbell/devel/ecos/builds/viper/ram.tpm/io/i2c/current'
arm-elf-gcc -c  -I/home/icampbell/devel/ecos/builds/viper/ram.tpm/install/include -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/tests -I. -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/ -finline-limit=7000 -mcpu=xscale -Wall -Wpointer-arith  -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions   -mapcs-frame -Wp,-MD,src/i2c.tmp -o src/io_i2c_i2c.o /home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx
/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx: In constructor `cyg_i2c_init::cyg_i2c_init()':
/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx:100: error: comparison between distinct pointer types `void (*)(const cyg_i2c_bus*)' and `void (*)(cyg_i2c_bus*)' lacks a cast
make[1]: *** [src/i2c.o.d] Error 1
make[1]: Leaving directory `/home/icampbell/devel/ecos/builds/viper/ram.tpm/io/i2c/current'

Fix is to compare against NULL instead of constructing a type specific
NULL explicitly. I guess the " != NULL" could even be dropped entirely
if that is preferable.

Using gcc 4.x ?
i2c_init_fn() in i2c.h is defined to take a non-const arg, so the cast here does not need a const and it works.
this is what I changed locally to get it working


#ifdef CYGDBG_USE_ASSERTS
         bus->i2c_current_device = (const cyg_i2c_device*) 0;
#endif
-        if ((void (*)(const cyg_i2c_bus*))0 != bus->i2c_init_fn) {
+        if ((void (*)(cyg_i2c_bus*))0 != bus->i2c_init_fn) {
             (*bus->i2c_init_fn)(bus);
         }
     }
}

but comparing to NULL as you did seems cleaner to me.

Jani


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]