I wrote more on this in another thread: Use-cases for modules not implicitly included in the build
This is how modules work in every language except Go. IDEs that auto-generate use statements may change this, but I haven’t used such IDEs (when I use Java I add use statements manually). I used Xcode, where adding to the project and adding to the build (target) are orthogonal.
Makefiles with wildcards cause problems when there are merge files left by git (foo_BASE_X.c), so such implicit behavior is a problem and it is usually avoided by specifying included files more carefully.
For tests there’s a tests directory. For other “unused” files with side effects there’s mod and use to include them.