[Top][All Lists]

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

[avr-gcc-list] Bizarre string problem, part 3

From: André - BOL
Subject: [avr-gcc-list] Bizarre string problem, part 3
Date: Wed, 8 Sep 2004 21:30:27 -0300

First, I'd like to thank everybody for the tips, but they haven't
worked. I formulated a new very simple example to demonstrate the
problem I'm facing.
Suppose I "initialize" a variable in some different and equivalent ways:
    char a[10]  = {'T', 'T', 'T', 'T', 'T' };    
    char b[]      = "TTTTTTT";
    char c[10];      c[0]='T';    c[1]='T';     c[2]='T';      c[3]='T';
//i think this can't be called an initialization!!!
    char *d      = "TTTTTTT"
    now, I perform the test
    if ( x[2] == 'T' ) printf("hi");    // x = a, b, c or d
    All examples are LEGAL STANDARD PURE C. I chose size 10 and the 3rd
( [2] ! ) element to avoid avoid any doubts that I had enougth space
reserved, and that I took the correct character. All tests should return
true and print "hi". My example ttest.c is to be run on Pc and shows
exactly that with printf's
    PROBLEM: when using the very same code on the ATMEGA, changing the
printf's for "turn on led 1", "turn on led 2", etc., only the third char
sequence (C) causes correct evaluation of the if expression (i can see
that, because I have the leds correctly connected and only the 3rd one
    I tryed this under WINDOWS AND UNDER LINUX, using avr-gcc. 
    Compilation and downloading commands:
avr-gcc -g -mmcu=atmega32 -Wall -o t.o t.c 
avr-objcopy -j .text -O ihex t.o t.hex
uisp -dprog=dapa --erase
uisp -dprog=dapa --upload if=t.hex -dno-poll -v=3 --hash=32

Attachment: t.c
Description: Text document

Attachment: ttest.c
Description: Text document

reply via email to

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