-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Few compile errors when building using an Atmega128 #502
Comments
The problem is in this call This can cause file corruption since the state of the file is lost when the constructed object is destroyed on return from |
So I changed #define FILE_COPY_CONSTRUCTOR_PRIVATE 1 to #define FILE_COPY_CONSTRUCTOR_PRIVATE 2 and the problem went away but can you explain why that happened? |
I disable the copy constructor since SdFat is designed to have only one instance of the File object for an open file. The state of the file is maintained in the file object. If you call a function with a copy of the file object, any changes of the file state will be lost. See this. You should design functions with File object arguments as call by reference or call by pointer, not call by value.
You are lucky that it works in your app but if you have problems don't post an issue. |
Atmega128 is an AVR / Megacore using the Arduino framework so presumed sdfat would compile without errors but I got a few:
.pio\libdeps\Upload_ISP\PCM\TMRpcm.cpp:1442:61: error: use of deleted function 'SdFile::SdFile(const SdFile&)'
unsigned long pos = searchMainTags(xFile, datStr);
^
In file included from .pio\libdeps\Upload_ISP\PCM\TMRpcm.cpp:9:0:
.pio\libdeps\Upload_ISP\SdFat\src/SdFat.h:468:7: note: 'SdFile::SdFile(const SdFile&)' is implicitly deleted because the default definition would be ill-formed:
class SdFile : public PrintFile {
^~~~~~
.pio\libdeps\Upload_ISP\SdFat\src/SdFat.h:468:7: error: use of deleted function 'PrintFile::PrintFile(const PrintFile&)'
In file included from .pio\libdeps\Upload_ISP\SdFat\src/ExFatLib/ExFatFile.h:883:0,
from .pio\libdeps\Upload_ISP\SdFat\src/ExFatLib/ExFatVolume.h:27,
from .pio\libdeps\Upload_ISP\SdFat\src/ExFatLib/ExFatLib.h:28,
from .pio\libdeps\Upload_ISP\SdFat\src/SdFat.h:31,
from .pio\libdeps\Upload_ISP\PCM\TMRpcm.cpp:9:
.pio\libdeps\Upload_ISP\SdFat\src/ExFatLib/../common/ArduinoFiles.h:43:7: note: 'PrintFile::PrintFile(const PrintFile&)' is implicitly deleted because the
default definition would be ill-formed:
class PrintFile : public print_t, public BaseFile {
^~~~~~~~~
.pio\libdeps\Upload_ISP\SdFat\src/ExFatLib/../common/ArduinoFiles.h:43:7: error: 'FsBaseFile::FsBaseFile(const FsBaseFile&)' is private within this context
In file included from .pio\libdeps\Upload_ISP\SdFat\src/FsLib/FsLib.h:31:0,
from .pio\libdeps\Upload_ISP\SdFat\src/SdFat.h:33,
from .pio\libdeps\Upload_ISP\PCM\TMRpcm.cpp:9:
.pio\libdeps\Upload_ISP\SdFat\src/FsLib/FsFile.h:75:3: note: declared private here
The text was updated successfully, but these errors were encountered: