I created a .h, .cpp, keywords.txt, and .ino files that compile and work as expected. Then I created the files that are attached. I have a directory called Fdr that contains the .h, .cpp, and keywords.txt files. It is within my libraries directory just like the files that work.
The compiler says:
...
Compiling sketch...
"C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9206 "-DUSB_MANUFACTURER="Unknown"" "-DUSB_PRODUCT="SparkFun Pro Micro"" "-IC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino" "-IC:\Users\rgspa\Documents\ArduinoData\packages\SparkFun\hardware\avr\1.1.13\variants\promicro" "-IC:\Users\Owner\Arduino\arduinosketchfolder\libraries\Fdr" "-IC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src" "C:\Users\rgspa\AppData\Local\Temp\arduino_build_109682\sketch\FlightDataRecorder16.ino.cpp" -o "C:\Users\rgspa\AppData\Local\Temp\arduino_build_109682\sketch\FlightDataRecorder16.ino.cpp.o"
C:\Users\Owner\Documents\Rick\Teaching\Glendale Community College\balloon class\Arduino\SOFTWARE\FlightDataRecorder16\FlightDataRecorder16.ino: In function 'void loop()':
FlightDataRecorder16:37:3: error: 'fdr' was not declared in this scope
** fdr.Pointers(PointerArray);**//send pointer array to the library
^~~
C:\Users\Owner\Documents\Rick\Teaching\Glendale Community College\balloon class\Arduino\SOFTWARE\FlightDataRecorder16\FlightDataRecorder16.ino:37:3: note: suggested alternative: 'Fdr'
fdr.Pointers(PointerArray);//send pointer array to the library
^~~
Fdr
Using library Fdr in folder: C:\Users\Owner\Arduino\arduinosketchfolder\libraries\Fdr (legacy)
Using library Wire at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire
exit status 1 'fdr' was not declared in this scope
I have repeatedly compared my working files to the attached files and cannot see what I've done wrong. Your help would be greatly appreciated!
In the example that works, it was lower case even though that made no sense to me. I changed fdr to Fdr and got:
C:\Users\Owner\Documents\Rick\Teaching\Glendale Community College\balloon class\Arduino\SOFTWARE\FlightDataRecorder16\FlightDataRecorder16.ino: In function 'void setup()':
FlightDataRecorder16:30:6: error: request for member 'Pointers' in 'Fdr', which is of non-class type 'Fdr()'
** Fdr.Pointers(PointerArray);//send pointer array to the library**
^~~~~~~~
Using library Fdr in folder: C:\Users\Owner\Arduino\arduinosketchfolder\libraries\Fdr (legacy)
Using library Wire at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire
exit status 1
request for member 'Pointers' in 'Fdr', which is of non-class type 'Fdr()'
If I comment out Fdr.Pointers(PointerArray) or fdr.Pointers(PointerArray), the compiler errors go away so I think Fdr Fdr() is not the problem. Note that I have Fdr Fdr() near the top of the file and have it commented out at line 25.
Close, but not quite. The compiler would interpret "Fdr ourFdr();" as a prototype for a function named "ourFdr" that takes no arguments and returns an object of the "Fdr" class.
If the constructor for the "Fdr" class takes no arguments, use ""Fdr ourFdr;"
That seems to be a huge amount of code. Did you build the library step-by-step, adding one function at a time then compiled and tested it? If so, it should be pretty simple to go back to the last working version and figure out what you broke with the most recent addition.
However, if you just plopped it all down at once, then, IMO, it's going to be more difficult. In that case, I'd start over with a completely blank project. Add in one feature at a time. Then, compile and integration test it. Only move on to the next feature when the previous one is working.
I'd also keep all the files (.ino, .h, cpp) in one project folder until everything is working. Then you can more the "library" to ".../sketchbook/libraries". Although, this thing seems so specialized, do you really think it will be integrated into more than one project? If not, there's really no point in moving some of it to the libraries folder.
gfvalvo:
Close, but not quite. The compiler would interpret "Fdr ourFdr();" as a prototype for a function named "ourFdr" that takes no arguments and returns an object of the "Fdr" class.
If the constructor for the "Fdr" class takes no arguments, use ""Fdr ourFdr;"
I started with my program that ran with no known bugs and needed to move it into a library. I now see that doing it in one step was bad news. I did comment out and #ifdef out all of the code I added but must have missed something since it won't compile without errors.
Time to start over.
Thanks for your help,
Rick
PS: this is only about half of the code. The other half is in another Pro Micro dedicated to an Iridium modem.
" Although, this thing seems so specialized, do you really think it will be integrated into more than one project? If not, there's really no point in moving some of it to the libraries folder."
My problem is that students hack into my code and break it. Placing this code into a library will greatly reduce and maybe eliminate this hacking. They are not being malicious, just confused.
The students need to add to the calling program, just not to my functions. I plan to give them a very small file that they can modify plus a list of the functions they can call.