I encounter problems on a drum plugin that read PCMFiles.
It is working on windows but not on mac.
Do somebody know if this part of code is problemaic for mac using?
You’re creating a 4-character array, then writing a 5-byte string into it (5 because of the trailing null character). For me, Visual Studio refuses to compile it:
test.cpp:12:21: error: initializer-string for array of chars is too long [-fpermissive]
char pathName[4] = “PCM/”;
Do you not get a compiler error for that on your platform, or at least a warning?
But that aside, you then append another string into the end of that 4-character buffer, stomping off into the surrounding memory by the length of tableName. This is undefined behaviour on any platform - you’re (un)lucky it worked anywhere!
You’re writing in an odd hybrid of C and C++, and falling into C traps that C++ fixes. If you use std::string rather than character arrays, you’ll avoid problem like this.
Sorry I ve just correct this line when posting the question because it was writed “char pathName[100] = “PCM/”;” and though it was a bit too much
just change to char pathName[100] = “PCM/”; as it was originally and it should compile.
Sorry