Home > Backend Development > C++ > How to Enable C 11 Support in Qt Creator for Compiling C 11 Code?

How to Enable C 11 Support in Qt Creator for Compiling C 11 Code?

Mary-Kate Olsen
Release: 2024-10-27 10:12:02
Original
960 people have browsed it

How to Enable C  11 Support in Qt Creator for Compiling C  11 Code?

Enabling C 11 in Qt Creator: A Step-by-Step Guide

Qt Creator 2.7.0 is reported to support C 11, but it may require some configurations to enable it. If you encounter errors like "range based for loops are not allowed in c 98 mode," despite trying to compile C 11 code, follow these instructions to enable C 11 support:

For Qt 4.8 and GCC/Clang:

  • Open your .pro file (Qt project file).
  • Add the following line:
QMAKE_CXXFLAGS += -std=c++11
Copy after login

(or QMAKE_CXXFLAGS = -std=c 0x)

For Qt 5:

  • Add the following line to your .pro file:
CONFIG += c++11
Copy after login

Save your changes and rebuild your project. This should resolve the errors and allow you to compile and run C 11 code in Qt Creator.

The above is the detailed content of How to Enable C 11 Support in Qt Creator for Compiling C 11 Code?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template