From: Krishnendu C. <kri...@gm...> - 2012-09-05 08:46:08
|
Hi folks, I am facing some problem using inline functions on mcs51 port. Consider the following code: #include <string.h> int n[10]; inline int *address (void) { return &n[0]; } inline int size (void) { return sizeof (n); } void main (void) { memset (address(), 0, size()); } When it is compiled with --std-c99 switch, it generates the following error -:0: error 20: Undefined identifier '__00010001' main.c:7: error 47: indirections to different types assignment from type 'int near* fixed' to type 'int fixed' -:0: error 20: Undefined identifier '__00010001' -:0: warning 127: non-pointer type cast to generic pointer from type 'int fixed' to type 'void generic* fixed' The error prevails with --std-sdcc99, --model-large, and --stack-auto options. Another observation is, the inline functions create problem only when they return pointer. However, if the returned value is stored in a local variable before being used, it compiles fine. For example void main (void) { int *addr = address; memset (addr, 0, size()); } I am using sdcc 3.2.0, compiled with gcc on Fedora 15. The gcc -v produces Using built-in specs. COLLECT_GCC=/usr/bin/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.3/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla--enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC) Is --std-c99 and inline implementation still pending, or am I missing some point? Thanks, Krish |