But compilation fails with several (expected) errors because SQLite is C code while I’m trying to compile it in a C++ file.
The errors I’m getting are about assignment of void* to other pointers, which apparently is allowed “as is” in C but require a formal cast in C++.
Any magic trick to circumvent the problem?
I’ve tried surrounding the whole section in extern "C" { } but that has no effect
I don’t know if Projucer / CMake JUCE will do the right thing with that “my_module.c”, i.e. mark it for building with a C compiler
Most importantly, my_module will also contain CPP files so its main files would end up being:
my_module.h
my_module.cpp
my_module.c
With my_module.h being something like:
#include "sqlite/sqlite.h"
#include "presets/PresetManager.h" // A class provided by the module, which uses sqlite3
// ... more .h containing declaration of more classes
Such a .h works fine when included by my_module.cpp, but because it contains classes declarations, it would fail miserably when included at the top of my_module.c
Thank you both @jrlanglois and @RolandMR.
Regarding vflib, I don’t think it is maintained any more but the source code for the inclusion of sqlite can certainly be of inspiration.
And as you can see there’s an obvious overwriting problem, which results in linker errors because the symbols from either the .cpp or the .c get obliterated when the other of the two files is compiled.
An elegant solution that I found is to convince Visual Studio to change its naming scheme for objects to:
P.S. in Xcode this doesn’t appear to be a problem because it is smart enough to realize that two sources would yield object files with the same name, and in that case it appends an unique string to both object filenames so they don’t clash, e.g.
It may be easier to give them unique names such as mymodule_core.cpp and mymodule_util.c and then you don’t need to adjust compiler settings that’ll probably just get overwritten by the Projucer.
Thank you for pointing this out. Especially because it made me reconsider what I now recognize a false assumption of mine.
I believed that, for a module named “my_module”, the module files were forced to have the same name with different extensions (“my_module.h”, “my_module.cpp”, “my_module.mm”, and, therefore, also “my_module.c”), and that any suffix added to that pattern could only be one of the “special” suffixes for e.g. platform or plug-in format ("_Linux", “_AAX”, etc.)
Now, re-reading the module specification, I realized that the suffix can be any, and only those specific suffixes are dealt with in a special manner. All the others are always compiled.
I think I’ll explicitly name that file “my_module_sqlite.c” and that’s it.
Thanks everyone
I’ll follow up on this just to note that the above change causes the build time to increase significantly, between 200% and 300% from some tests with Debug builds.
Yeah you read it right, it takes from two to three times longer to build when that setting is changed.
This side-effect is obviously unacceptable, therefore I’ll revert that change, but it’s also inexplicable to me… why should it cause such a slowdown? Could it be the presence of the %(Macros) ?