[Top][All Lists]

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

[avr-gcc-list] differences between "char *var" and "char var[]"

From: Tyler Hall
Subject: [avr-gcc-list] differences between "char *var" and "char var[]"
Date: Sat, 19 Apr 2003 14:40:59 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.0.2) Gecko/20021216

If I do the following:

typedef char my_prog_char __attribute__ (( progmem ));
my_prog_char gMyProgString[] __attribute__ (( progmem )) = "XYZ";

The initial "XYZ" string will properly be thrown into the .progmem.data section, which merges to the .text section. But if I instead do this:

typedef char my_prog_char __attribute__ (( progmem ));
my_prog_char *gMyProgString __attribute__ (( progmem )) = "XYZ";

The initial "XYZ" string will be thrown into the .data section.

My problem is that I want to do a typedef or something that let's me do this:

prog_string my_array[] = {

And each string gets the progmem attribute tagged to it. Unfortunately, I can't typedef prog_string like this:
typedef prog_char prog_string[] __attribute__ (( progmem ))

because the compiler complains about the open-ended array without initial value.

Can someone explain how gcc treats pointers to char (char *var) differently than arrays of char (char var[]) and why gcc treats initial data differently depending on which form is chosen?


reply via email to

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