0

I started programming in C++ on my mac. So far, I just write my code in a text editor (Sublime), and run it from terminal using the 'make file.cpp' command and then run it with './file.cpp'.

It worked until now, but with more elaborate code I get an error that my C++ version has to be at least C++11. So I was wondering how to change the parameters of the 'make' command to be able to change the C++ version compiled in C++14 for example.

I understand that using 'makefile' is easier, but is it still possible to change the 'make' parameters?

Thank you very much

Ðаn
  • 10,934
  • 11
  • 59
  • 95
  • You may be confused - The `make` command reads and interprets your project's `Makefile`. They are both part of the same thing. You need to edit `Makefile` (OR whatever is *generating* your `Makefile`). – 0x5453 Mar 08 '21 at 22:47
  • `make` is a build system or build tool. In order to compile something, you use a compiler rather. However, `make` uses so-called Makefiles in order to define how to build something, which can include the use of a compiler. However: You never call `make x.cpp`, because the argument is a target (e.g. executable) not the source file, so I guess you have something different and special. I don't know your system though. Please, as a new user here, take the [tour] and read [ask]. – Ulrich Eckhardt Mar 08 '21 at 22:50
  • @0x5453 Technically, you can use `make` without a Makefile (https://stackoverflow.com/questions/15745241/using-the-make-command-without-makefiles), because it has some implicit rules. But I fail to see point in that. – Yksisarvinen Mar 08 '21 at 22:50
  • Since implicit `make` rules are very basic, I suppose you could simply replace `make` with `clang` and your problem will be solved - you can pass arguments to compiler directly (`clang -std=c++14 main.cpp`) – Yksisarvinen Mar 08 '21 at 22:52
  • In linux, use may use the command "man make". (on my system) This reports more than 40 options that are modifiers for the "make" command. Example: -k modifies the compiler operation to "keep going", i.e. "Continue as much as possible after an error". 'make' is what I use ... you might research alternatives to make, which, for some people, are easier to tackle. – 2785528 Mar 09 '21 at 00:20
  • Thanks to everyone ! Eventually I could find my answer here : [link](https://stackoverflow.com/questions/41519451/make-is-not-using-std-c11-option-for-g) – thegimp Mar 09 '21 at 00:40

0 Answers0