avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Int32 Support


From: User Tomdean
Subject: Re: [avr-gcc-list] Int32 Support
Date: Mon, 18 Sep 2006 13:51:49 -0700 (PDT)

Something I forget:  C is a glorified assembly language!

# cat xx.c
#include <stdio.h>
int main() {
  uint8_t  z = sizeof(uint32_t);
  uint32_t a = 0x00000001<<14;
  uint32_t b = 0x00000001<<15;
  uint32_t c = 0x00000001<<16;   /* produces a warning - see below */
  return -1;
}

# avr-gcc --version
avr-gcc (GCC) 3.4.6
...

# avr-gcc -Wall -I/usr/local/avr/include/ -o xx.elf xx.c
xx.c: In function `main':
xx.c:6: warning: left shift count >= width of type
xx.c:3: warning: unused variable `z'
xx.c:4: warning: unused variable `a'
xx.c:5: warning: unused variable `b'
xx.c:6: warning: unused variable `c'

And, avr-objdump shows the same results.

Changing the code to
#cat xx.c
#include <stdio.h>
int main() {
  uint8_t  z = sizeof(uint32_t);
  uint32_t a = (uint32_t)1<<14;
  uint32_t b = (uint32_t)1<<15;
  uint32_t c = (uint32_t)1<<16;
  return -1;
}

Produces the results you want.

tomdean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]