For future reference to myself and to whoever is interested in doing the same, I confirm that it’s possible but with an important caveat:
in Visual Studio, by default the sources are compiled to objects with the following naming scheme:
my_module.cpp -> my_module.obj
my_module.c -> my_module.obj
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:
my_module.cpp -> my_module.cpp.obj
my_module.c -> my_module.c.obj
Which is obtained by setting
"C/C++" -> "Output Files" -> "Object File name"
as shown in the image below:
I wasn’t aware of their existence, but it appears there are more of those %(Macro) listed here: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata
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.