I successfully compile the program at the Question How to pass a string type path to boost::filesystem:path's constructor? However, the output result shows more than the expected one.
Folder status: 0
Bus error: 10
The first line is the only expected result. I do not understand why the second one comes?
I get the following debug information by gdb:
(gdb) run
Starting program: /Users/ZL/Desktop/mtfsg
Reading symbols for shared libraries ++++............................. done
Folder status: 0
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5fc005a0
0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>,
std::allocator<char>>::~basic_string ()
(gdb) bt
#0 0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string ()
#1 0x00000001000018dd in main () at m.cpp:12
Finally, I find the point of the error in my code:
In class OSxFS (tfs.h file), the method “string ShowStatus()” has an incorrect return type “string”. This method does not need a return value since its functionality is only to print the directory (folder) status on the screen. So, I replace the “string” return type by “void”.
The original code of method “string ShowStatus()”
The correct code: