cxx-modules-sandbox icon indicating copy to clipboard operation
cxx-modules-sandbox copied to clipboard

Don't use .mpp extension for non modules

Open RedBeard0531 opened this issue 6 years ago • 3 comments
trafficstars

Ideally you wouldn't use that extension at all because clang silently doesn't emit object files for it, requiring -x c++. But if you think that is important, at the very least it should only be done for actual modules. https://github.com/mathstuf/cxx-modules-sandbox/blob/master/link-use/use.mpp is particularly incorrect because currently main() isn't allowed to be defined inside of a module.

RedBeard0531 avatar Jul 22 '19 11:07 RedBeard0531

I'm partial to the "extensions don't matter too much" view because it's all C++ code and the build system can't trust any of it until it scans the code anyways. At that point, we know what kind it is and we can just add whatever flags are necessary to make it be accepted. Sure, assumptions about the code based on the extension are fine, but they shouldn't be pre-destined because of it. If someone really wants to put C++ code into a .js file, I'm not going to question their life choices :) .

mathstuf avatar Feb 25 '22 19:02 mathstuf

I agree with your viewpoint at a high level. How about renaming everything to .cpp? Build systems should be able to handle that.

My issue was with simultaneously introducing a new extension to distinguish modular code from non modular (which I agree is of questionable utility), and also using the modular extension for non modular code. It feels contradictory.

RedBeard0531 avatar Feb 25 '22 19:02 RedBeard0531

It was needed for build2 support since it requires such an extension. FWIW, it started off as .cpp in the beginning :) .

mathstuf avatar Feb 25 '22 20:02 mathstuf