[ECOS] Constants generated by CDL

David Brennan eCos@brennanhome.com
Fri Dec 10 07:04:00 GMT 2004


Actually the problem is if the number is a decimal number:
#define TTT 3229683712
#define putU(x,y) x##y
#define tounsigned(x) putU(x,U)

unsigned int i = TTT;
unsigned int j = tounsigned(TTT);

gives:
dbrennan@brennan ~
$ i386-elf-gcc x.c
x.c:5: warning: decimal constant is so large that it is unsigned
/opt/ecos/gnutools/i386-elf/bin/../lib/gcc-lib/i386-elf/3.2.3/../../../../i386-lf/bin/ld: 
crt0.o: No such file: No such file or directory
collect2: ld returned 1 exit status

dbrennan@brennan ~
$ gcc x.c
x.c:5: warning: this decimal constant is unsigned only in ISO C90
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../libcygwin.a(libcmain.o)(.text+0xc): 
undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status

So yes, it would fix my problem. I did not try adding the extra layer in 
my experimentations. But I would still rather have more control over the 
format of the number spit out by CDL. CDL could also put the number out 
in hex and I wouldn't need to do anything. But it is a calculated number 
(ORing together bit field options.)

Thanks
David

sandeep wrote:

> David Brennan wrote:
>
>> Is there some sort of keyword that can be put in CDL statement so the 
>> #define is set-up as an unsigned number? I am calculating a unsigned 
>> integer by combining bits and if the most significant bit is set then 
>> I get a warning in the compiler:
>> /ecos-c/cygwin/opt/ecos/ecos-cvs/ecos/packages/io/vme/universe/current/src/vme_master.c:217: 
>> warning: decimal constant is so large that it is unsigned
>> I get this when I put the constant as the initialization value of an 
>> unsigned integer. Looking up the documentation for gcc, I found that 
>> if I add a U to the end of the constant, the warning will go away. I 
>> tested this by manually changing the install/include/pkgconf/ include 
>> file that defines the constant. But I can't figure out any way to do 
>> that in CDL. I tried just casting it in the C code, but that doesn't 
>> help.
>> Any suggestions?
>
>
> [/tmp]cat x.c
> #define TTT 0xff8989ff
> #define putU(x,y) x##y
> #define tounsigned(x) putU(x,U)
>
> int i = TTT, j = tounsigned(TTT);
> [/tmp]cpp x.c
> # 1 "x.c"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "x.c"
>
>
>
>
> int i = 0xff8989ff, j = 0xff8989ffU;
> [/tmp]cpp --version
> cpp (GCC) 3.2.3
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There 
> is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> ------------------------------------------------
>
> will a trick like that work around your problem in application?
>
> is it warning only? in that case, casting should work fine with your 
> code (in general).
>
> i tried "gcc -Wall -c x.c" but didn't get any warning.
>
> sandeep
>
>
>

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list