Can structs be kept in program memory even when those structs include strings?
In this example:
#include <avr/pgmspace.h>
typedef struct
{
uint8_t x:4, y:4;
char *name;
}
Pin;
//#define P(str) PSTR(str)
#define P(str) str
Pin PROGMEM pin[] =
{
{ 0, 0, P("PC6")},
{ 0, 1, P("PD0")},
};
int main( void)
{
while ( 1)
{
}
}
.. if "PROGMEM" is omitted then I get:
flash: 112 bytes
RAM: 14 bytes
When "PROGMEM" is left in ( as above) I get:
flash: 112 bytes
RAM: 8 bytes
..so the "x" and "y" parts of the struct along with the 16-bit string pointers
are now in program memory yet the strings ( 2 * (strlen("PC6") + 1)) still
consume RAM. When I define "P" as an alias for "PSTR" I get:
example.c:16: error: braced-group within expression allowed only inside a
function
example.c:17: error: braced-group within expression allowed only inside a
function
make: *** [example.o] Error 1
Is there some way that the whole structure can be kept in program memory?
Thanks in advance,
- neil
_______________________________________________
AVR-chat mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-chat