Suggestion : warining when using == instead of = in a Makefile variable assignation
Jerome Saint-Martin <[email protected]> Mon, 28 Jul 2025 08:59:52 +0000
| Newsgroups | gmane.comp.gnu.make.bugs |
|---|---|
| Message-ID | <GV2PR10MB67430215B606BDFC08605E71DC5AA@GV2PR10MB6743.EURPRD10.PROD.OUTLOOK.COM> |
Hello GNU Make team, Recently, I spent quite some time debugging a Makefile issue, only to realize that I had mistakenly written `==` instead of `=` when assigning a variable (e.g., `CXX == g++` instead of `CXX = g++`). Make simply reported an undefined variable later on, which made the root cause harder to spot. This kind of mistake is easy to make, especially for C++ developers who are used to writing `==` in conditionals. In C++, compilers like GCC emit warnings such as “value computed is not used” when an expression like `x == y;` is written outside a conditional context. Would it be feasible for GNU Make to emit a warning when `==` is encountered in a context that looks like a variable assignment, but isn’t a conditional test? I believe this could help many users catch such typos early. Thanks for considering this suggestion, and thank you for your work on Make! Best regards, Jerome