What do these common C++ compiler flags do? [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm a starter in C++. I'm still confused about the flags in my makefile.
-c. -o. -Wall. -g. -std=c++0x.
Can any one tell me what all these common flags do?

Only the last flag (compiler command option) is very compiler-specific. The first three or four have been de facto standard since, well, the early or mid 1980s, I think. Of course there’s no guarantee that any particular compiler will understand them, but they’re not uncommon.
Note: while Visual C++ accepts the - flag prefix notation, it is usually used with / as flag prefix, since that’s the common convention in Windows.
-c
Compile only, don't link.
-o
Specifies an output file, e.g. executable. Unfortunately deprecated
for Visual C++ compiler. With Visual C++ use e.g. /Fe.
-Wall
With g++ all practical warnings. With Visual C++ all warnings including all sillywarnings, and that's a bunch!
-g
Generate debug information. Supported by many compilers but not Visual C++.
Then,
-std=c++0x
is a g++ compiler-specific option that specifies sort of C++11 standard. As I recall the difference from -std=c++11, for newer compiler versions that accept both, is that the former still permits some g++-specific language extensions.

Those are not "c++ flags", those are flags for a compiler, presumably it's g++ from the gcc suite.
All those flags are documented on both the online and the offline docs, the offline docs are probably easier to browse for a beginner due to the fact that you can just open the pdf in a viewer and use the search engine to search for a word.
This are the manuals for gcc.

Related

Regular expression implementation that can be use for gcc4.8 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Regular expressions will not work on gcc4.8 based on what I found out.
During cross compile I encountered run time errors with regards to regular expressions.
Do you know other ways how can i work with regex at gcc4.8?
I am thinking of creating my own but I wander if there is already available that can be use.
GCC 4.8 is really old (and no more maintained in 2020).
Consider updating it -in October 2020- to GCC 10 (whose source code you could compile) and read documentation about invoking GCC and using GDB. I suggest compiling with g++ -Wall -Wextra -g using a recent GCC.
Read at least the C++11 standard n3337 and a good C++ programming book and more about the #include <regex> standard header.
On Linux and POSIX systems, you could use regex(3). The source code is available, since open source (in e.g. the GNU libc or the musl-libc) and with permission you can adapt it to your working context.
You could also use Qt or POCO. Both have some regular expressions facilities and are open source. So you can study their source code implementation of regular expressions and their relation to push down automata. Read also about recursive descent parsers and consider using parser generators (if allowed) such as GNU bison, flex, or ANTLR. If performance is a major concern, consider using (with permission) code generating libraries like libgccjit, asmjit, GNU lightning, tinycc.
Of course, read the Dragon book. It explains the basic concepts for regular expressions. Read also recent papers to ACM SIGPLAN conferences.
If your management requires specifically GCC 4.8 (I would consider changing jobs with such a stupid requirement - since cross compiling GCC 10 is quite easy, and GCC improved a lot in five years), you should at least ask permission to compile some existing regular expression open source libraries (you'll find many of them on github or gitlab), or in boost.
Consider of course asking permission to use a recent Clang compiler (you could compile it from its source code, since it is open source), the Clang static analyzer, and perhaps Frama-C++, and to read this draft report. See also the CHARIOT and DECODER European projects.
PS. Cross-compiling GCC 10 takes one or two days (if you are a newbie). Writing your regular expression library could take you several weeks.

Is C++ an open-source project? Which community developes it? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Not suitable for this site
Improve this question
I have some questions about C++:
Is C++ an open-source project like Linux, Qt, ... or not?
Which community maintains C++ and develops new versions?
If it is open-source where can one access the source code for C++
implementations?
C++ itself is only a description what the language should be,
without a definite implementation.
Anyone can make his own implementations (compiler etc, runtime library, ...)
and call it C++ if it fits to the description.
http://www.open-std.org/jtc1/sc22/wg21/
And if a implementation is open source depends on the creator.
Examples of implementation (parts):
GCC/G++, libc/libc++, clang (++ too), Visual studio and MS´ runtime...
C++ is developed by an ISO standard committee. There's also a C++ foundation that runs a web site you might want to read.
C++ itself is a language, not a specific implementation, so there's no source code available for the standard/language itself.
Some C++ implementations are open source (e.g., Gnu and Clang).
C++ is a code standard defined by the International Organization of Standardization (ISO). There are many different implementations of the language, but they all tend to conform to C++11. Unlike Linux or Qt, C++ is just a standard, and to use any code written in the language you'll need a compiler. The major compilers (list from Wikipedia) are LLVM Clang, GCC, Microsoft Visual C++, and the Intel C++ Compiler.
C++ revisions are dealt with by ISO, and are influenced primarily by the maintainers of the above four implementations.
Clang and GCC are both open-source, I'm sure if you poke around you can find other conforming compilers but those are the two most used.
C++ is an ISO standard. There are many implementation of compilers (and linkers). GCC is an open source project of many compilers one of which is the C++ compiler, g++:
http://gcc.gnu.org/projects/cxx0x.html

What is the most complete and reliable open source C++11 IDE for Windows? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I don't intend this to be an opinion question and I am deliberately avoiding the word "best" for that reason. To frame my question differently;
Is there a fully C++11 compatible Open Source and free (as in free speech, beer and lunch, not as in Express, Lite, Demo, etc.) IDE that provides stable syntax and error highlighting a la IntelliSense, that works out of the box with C++11, or at least with a minimal, easy to follow amount of work?
I am asking this question because I really like the VS2012 environment but have become frustrated with the lackluster degree of C++11 compatibility, and my license is due to expire anyway.
Have you tried the "Visual C++ Compiler November 2012 CTP" update? It adds support for several features (most notably variadic templates) to VC11. The library is not there, and this compiler update is not considered production-ready, but I've found it to be great for working on my projects and using C++11 code till the final product comes out.
Also, I have used Qt Creator (quite independent from the Qt toolkit) for GCC-based C++11 development and it's a great IDE.
First: it's not (mainly) the IDE that needs the C++11 Support, but the compiler. That being said - here are some options:
it is possible to integrate clang into VS2012 (check here: https://github.com/ishani/ClangVSx)
You can use any IDE that supports MINGW as compiler (Windows-GCC-Port) e.g. Eclipse CDT, QT Creator, Code::Blocks, DevCpp
You can use any IDE that supports Clang as compiler (e.g. Code::Blocks)
According to http://www.codelite.org/LiteEditor/ClangIntegration, you can configure codelite to use Clang for code completion vs. gcc. So depending on the IDE, the compiler might provide things like code completion.

what c++ norme i'm currently using? [duplicate]

This question already has answers here:
How to determine the version of the C++ standard used by the compiler?
(9 answers)
Closed 6 years ago.
Recently I had faced compiling errors in a c++ code I wrote so I've been asked if I was using a C++11 compiler, but honestly I don't know how to check on my compiler version ! so any idea how to figure this out ??
Btw I'm using codeblocks as an IDE which includes the GCC compiler and GDB debugger from MinGW. also if I'm compiling my c++ code under Linux what command should I run to know my compiler version ?
That can be a tricky question. C++11 refers to a version of the
standard, not to a version of the compiler. Different compilers, and
different versions of any given compiler, will typically implement a mix
of versions of the standard, at least for recent versions. More or
less, because any implementation of C++11 will be fairly new, and thus
probably fairly buggy.
Most compilers have options to output the version; many will output it
systematically in verbose mode. For g++, try g++ --version. Recent
versions of g++ do have some support for C++11, but you have to activate
it with -std=c++0x (rather than the usual -std=c++03 or
-std=c++98). As the name (c++0x, rather than c++11) indicates, it
is not truly C++11; it is an implementation of some (most?) of the
major new features, in a preliminary version based on various working
papers, and not the final standard.
(FWIW: I don't think any compiler fully implements all of C++11, but I'd
love to be proven wrong.)
You can find out your compiler version like this:
g++ --version
That doesn't tell you if you are using c++11. To use c++11 features, you would have to call the compiler with thr -std=c++0x flag:
g++ -std=c++0x ....
Bear in mind that gcc doesn't implement 100% of c++11 yet, and how much it implements depends on the version. See here for a table of supported features.
EDIT: strictly speaking, if you are using GCC you cannot be using a fully compliant c++11 compiler due to the missing features. But versions 4.6.1 onwards cover a great deal of the standard.
If you're in linux, checking the version is easy.
> gcc --version
Will tell you the version you have. Note that GCC C++11 support is incomplete still, you can find the details here: http://gcc.gnu.org/projects/cxx0x.html
I've used a few C++11 features myself, namely initializer lists, and the nullptr constant. I'm using GCC 4.6 and it's working fine.
edit: And yes, as #jaunchopanza said, you'll need the -std=c++0x compiler flag to make it work. If you're using Code::Blocks, just right-click on your project, choose Build options..., and check the item that says Have g++ follow the coming C++0x ISO C++ language standard [-std=c++0x]

How can I compile under C++11 standard in Ubuntu? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
How may I compile a C++ program under the C++11 standard in Ubuntu 11.04 with the most up-to-date compiler, at best using compiler from the distribution, i.e., pre-built package.
GCC 4.6 provides most of the C++11 features. One has only to add the flag -std=c++0x and can use range based for loops, strong enums, UTF strings, etc. For the list of features available in a given version of GCC one can check on http://gcc.gnu.org/projects/cxx0x.html.
Update in 2017: It seem GCC 7 and higher has full C++ 2011 compliance. The rest of the answer below was written in the GCC 4.7 era, and was correct when written in 2011.
Strictly speaking, I can not offer you any 100% C++ 2011 compliant open source compiler, because there aren't any that are 100% there yet.
It looks like you should stay with GCC for now, and GCC 4.6 binaries are included in recent Ubuntu distributions. C++ 2011 is incomplete in GCC 4.6 but contains a lot of 2011 stuff, more than Clang+llvm. It's more than 90% C++ 2011 feature complete. GCC 4.7 contains yet more stuff, but I don't see gcc-4.7 binary packages in Ubuntu 11.x yet, but you can check over here for another way to get gcc 4.7 binaries on ubuntu, or try AskUbuntu, a stackexchange powered site for ubuntu.
According to this page Clang+llvm does not yet offer full C++ 2011 standards compliance, either, and I haven't done the exact math but I see a lot more "No" entries on Clang, versus Gcc.