Go Down

Topic: Compiler cannot find pgmspace.h (Read 4262 times) previous topic - next topic

cyborg5

I'm brand-new to the Arduino and I'm trying to use PROGMEM to store some strings. All of the examples say that I should include "avr/pgmspace.h" however the program refuses to compile. I searched all over for it and found that several folders deep in a different directory. Basically when I unzipped the Windows package it created a folder called "Arduino 1.0" and it contains a subfolder "libraries" that contains all of the standard libraries. There is also "Arduino 1.0/hardware/tools/avr/avr/include/avr/pgmspace.h" which is the only copy of the include file that I can find.

Without going through a bunch of trial and error can someone tell me which of these deeply nested folders I need to copy to "Arduino 1.0/libraries" in order to get my program to compile. Is there something more beyond the "pgmspace.h" file that needs to be copied. Is there a something.cpp as well that I need?

liuzengqiang

You don't need to include that file. Arduino IDE with do that automatically. So delete the line with pgmspace.h
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Krodal

You can place strings in program space with F().
Like this: Serial.println(F("Hello, this string is in program space"));
There is also an sprintf_P, which also places the string in program space.

cyborg5

Thanks for the heads-up on the F() option. I'm actually creating an array of strings so I imagine I still have to do that long way using PROGMEM modifiers and an array of pointers?

By the way where in the documentation would I have found that F() feature?

Also when you said that AVR library is automatically included does that mean everything listed in this reference?

http://www.nongnu.org/avr-libc/user-manual/modules.html

Unrelated question while I'm at it… Does the compiler support macros just like regular C/C++ does. The language reference only talks about

#define Variable Value


PaulS

Quote
Does the compiler support macros just like regular C/C++ does.

Why wouldn't it? It IS a regular C++ compiler.
The art of getting good answers lies in asking good questions.

Krodal

Documentation for the F() macro ? I can't find it!

Normally everything is included. But with libraries you need to include some files, and sometimes also with normal sketches, some library include files are needed.

The gcc C/C++ compiler does support macros. It is the full gcc compiler. For macro's see this: http://gcc.gnu.org/onlinedocs/cpp/Macros.html

liuzengqiang

Not everything is included. Search Arduino.h in your computer and see what are included by default.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

dxw00d

Quote
Documentation for the F() macro ? I can't find it!


Its mentioned in the 1.0 release notes. http://arduino.cc/en/Main/ReleaseNotes

Quote
* Support has been added for printing strings stored in flash (program
  memory) rather than RAM. Wrap double-quoted strings in F() to indicate
  that they should be stored in flash, e.g. Serial.print(F("hello world")).

Go Up