Issue with my compiler not using C++11 with CLion on a Mac

  • C/C++
  • Thread starter member 428835
  • Start date
  • Tags
    Compiler Mac
In summary: No, I didn't. I don't have any reason to look at documentation for a product I don't use. My focus was on the mostly unreadable screenshot you sent.
  • #1
member 428835
The compiler is not using C++11 or greater on CLion. My CMakeLists.txt reads:
cmake_minimum_required(VERSION 3.24)
project(main)

set(CMAKE_CXX_STANDARD 17)

add_executable(main main.cpp)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

Any idea what's happening? C++11 worked when I first created the project, but now that I closed it the compiler seems to not work. Any help is greatly appreciated. I'd provide more files if I knew what was relevant.
 
Technology news on Phys.org
  • #2
joshmccraney said:
The compiler is not using C++11 or greater on CLion.
How do you know? Does your program use C++11 features that aren't present in whatever C++ standard that your compiler is actually using?
joshmccraney said:
Any idea what's happening? C++11 worked when I first created the project, but now that I closed it the compiler seems to not work.
What does "C++11 worked" mean? Telling us that something didn't work doesn't give us much to go on. How do you know that C++11 isn't working now? E.g., compiler error/warning messages, runtime errors, program behavior.
 
  • Like
Likes Vanadium 50
  • #3
Mark44 said:
E.g., compiler error/warning messages, runtime errors, program behavior.
And this isn't the first time either we've asked about error messages and their ilk,

It's pretty clear you ain't buyin' what were sellin' with respect to error messages and such. How do we convince you?
 
  • #4
Mark44 said:
How do you know? Does your program use C++11 features that aren't present in whatever C++ standard that your compiler is actually using?
Yes, as an immediate example, the line: std::vector<int> v = {2, 6, 5, 3, 8, 7, 1, 0};
gives the error:
error: non-aggregate type 'std::vector<int>' cannot be initialized with an initializer list
std::vector<int> v = {2, 6, 5, 3, 8, 7, 1, 0};

Also warnings with range-based for loops, etc.
Mark44 said:
What does "C++11 worked" mean? Telling us that something didn't work doesn't give us much to go on. How do you know that C++11 isn't working now? E.g., compiler error/warning messages, runtime errors, program behavior.
This means I wasn't getting these errors until I restarted CLion. It doesn't work now from the errors above and the c++11 warnings, which would not occur if I was actually using c++11 or higher. All I do is press the green arrow to run the code from the CLion interface.
 
  • #5
What you wrote gives us more to go on, so that's appreciated. However, since I don't use a Mac or CLion, I'm unable to extricate you from your problem. I'm hopeful that someone who is familiar with those computers and tools can weigh in here.
 
  • Like
Likes member 428835
  • #6
joshmccraney said:
All I do is press the green arrow to run the code from the CLion interface.
Given that support for makefiles is an experimental feature in CLion you need to do a bit more than that. In particular, unless you are very confident in all three of the following:
  1. using makefiles outside the CLion IDE (e.g. by running gcc from the command line);
  2. working with CLion to adjust settings and tools used in the compile path; and
  3. combining information from system documentation, error messages and other debugging techniques to work out what is going wrong and how to fix it,
I would say that you should either stop using makefiles and let CLion manage the build the way it is designed to or stop using CLion and use an IDE that is designed to work with makefiles.
 
  • Like
Likes member 428835, Mark44 and Vanadium 50
  • #7
Okay, I found the issue, which has a simple fix. It's detailed at CLion's website here. Attached is a screenshot for anyone who may struggle with this in the future: just change the run configs (see the arrow) from the .cpp file to the project. Very obvious now that I'm aware. Thanks for the help!
Screenshot 2023-03-09 at 8.20.46 PM.png
 
  • #8
A black arrow against a nearly identical black background isn't the easiest thing to read...
 
  • Like
Likes Vanadium 50
  • #9
Mark44 said:
A black arrow against a nearly identical black background isn't the easiest thing to read...
Yea couldn't figure out how to change it so i made i super thick. It stands out very clear to me though. I'd say the bigger issue is why the screenshot quality is so poor.
 
  • #10
joshmccraney said:
I'd say the bigger issue is why the screenshot quality is so poor.
  1. Your screen shot includes the whole screen. Including just a portion of the screen would have been clearer.
  2. White characters against a black background is not as clear as black characters against a white background.
 
  • #11
Mark44 said:
  1. Your screen shot includes the whole screen. Including just a portion of the screen would have been clearer.
  2. White characters against a black background is not as clear as black characters against a white background.
I assume you didn't look at the link I posted?
 
  • #12
joshmccraney said:
I assume you didn't look at the link I posted?
No, I didn't. I don't have any reason to look at documentation for a product I don't use. My focus was on the mostly unreadable screenshot you posted.
 
  • #13
Mark44 said:
No, I didn't. I don't have any reason to look at documentation for a product I don't use. My focus was on the mostly unreadable screenshot you posted.
Okay, thanks for your interest. My post details how I solved it
 

Similar threads

  • Programming and Computer Science
Replies
0
Views
286
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
6
Views
8K
  • Programming and Computer Science
Replies
20
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
39
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
841
Back
Top