warning: '__progmem__' attribute ignored

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
I'm developing on ATTiny2313 using AVRStudio/WinAVR 20070525.
While trying to place some strings in flash using like below

  const char errPWM1[]PROGMEM = "PWM param 1 err.Values:16(fwd), 17(bwd).Crt.value: ";
  const char errPWM2[]PROGMEM = "PWM param 2 err.Values: >=16.Crt.value: ";
  const char errPWM3[]PROGMEM = "PWM params error. Only 2 params required";

I'm getting warning: '__progmem__' attribute ignored and of course, I run out of memory.

The strings are meant to display on a LCD using Peter Fleury's lib
extern void lcd_puts_p(const char *progmem_s);

What am I missing :?:

thanks
Legi0n

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My crystal ball is just on repair... so I can only guess: you are
trying to initialize variables with automatic storage that way.
That cannot work.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

It is really essential to initialize const variables as a GLOBAL variables. Have you done it ??
If not do so !
This is probably the reason why yous get :

warning: '__progmem__' attribute ignored

By the way here you have a great tutorial about using PROGMEM:

https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=38003

Adam :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's not required to be global variables, but they ought to
be variables with static storage duration. All global
variables do have that, but it can also be applied to local ones.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dl8dtl wrote:
It's not required to be global variables, but they ought to
be variables with static storage duration.

Okey but even though I declere variable as static and non global it doesn`t work

When variable is global everything works fine

I am not sure but I can remember mentioning it in tutorial.

const uint8_t sine[] PROGMEM=
{
something

};

This code works only when I declare it as global.

Adam

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

const is not the same as static.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
const char errPWM1[]PROGMEM = "PWM ... .Crt.value: ";

I use exactly this same construct with no problems.

I know that whitespace is not supposed to matter, but I would try:

const char errPWM1 [] PROGMEM = "PWM param ... .Crt.value: ";

The other point that Jörg and company are making is not about the const declaration, but how you are using it. I have another section (the boot, as it happens) that uses strings defined as above. My declaration is different that yours, though:

void sendstring_P(uint16_t str_P);

and is called like this:

	sendstring_P( (uint16_t) boot_Monitor );

Your mileage may vary.

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I use exactly this same construct with no problems.

And as a global, it does work. However if it is a local variable, it must be declared static.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#include 
#include 

//this works
const char test0[] PROGMEM = "test"; 

int main(void){
//this works
static const char test1[] PROGMEM = "test"; 
//this doesn't
// warning: `__progmem__' attribute ignored    
const char test2[] PROGMEM = "test";
while(1);
return 0;
}

(edit- includes didn't show up correctly, edit5- forget it- you figure out the correct includes)

Last Edited: Mon. Dec 3, 2007 - 07:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:
const is not the same as static.

You are right :)
I don`t know why I was thinking about const as a static.
Now everything is clear :) :) :)

Good trying to help somebody else I am also learning ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:
Quote:
I use exactly this same construct with no problems.

And as a global, it does work. However if it is a local variable, it must be declared static.
Oops. :oops: Yup. But then, I never would have thought of using it as a local (I missed that part of the discussion). My coding style would never place a const as a local.

Live and learn!

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> My coding style would never place a const as a local.

Why not? It's good style to limit the scope to the minimum needed,
and e.g. if a string is only used inside a single function, it's
fine to declare it as a static object right there.

In effect, that's what the PSTR macro does, albeit it really creates
what I'd call a ``micro-scope'' only (no pun intended).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

static 6 characters
tutorial ... priceless!

thanks guys

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dl8dtl wrote:
> My coding style would never place a const as a local.

Why not? It's good style to limit the scope to the minimum needed, and e.g. if a string is only used inside a single function, it's fine to declare it as a static object right there.

Habit from the M$ world? I tend to organize strings into blocks, which is useful if you use resource sections (think internationalization). Once you get in the habit, *everything* goes there.

Like I said, purely personal habit. I don't expect others to follow it. I just need to remember that most other folks don't follow it! :D

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!