Posts

Showing posts with the label Gcc

A Simple Explanation Of What Is MinGW

Answer : MinGW is a complete GCC toolchain (including half a dozen frontends, such as C, C++, Ada, Go, and whatnot) for the Windows platform which compiles for and links to the Windows OS component C Runtime Library in msvcrt.dll. Rather it tries to be minimal (hence the name). This means, unlike Cygwin, MinGW does not attempt to offer a complete POSIX layer on top of Windows, but on the other hand it does not require you to link with a special compatibility library. It therefore also does not have any GPL-license implications for the programs you write (notable exception: profiling libraries, but you will not normally distribute those so that does not matter). The newer MinGW-w64 comes with a roughly 99% complete Windows API binding (excluding ATL and such) including x64 support and experimental ARM implementations. You may occasionally find some exotic constant undefined, but for what 99% of the people use 99% of the time, it just works perfectly well. You can also use t...

C11 In GCC?

Answer : The standard C11 header for threading is <threads.h> , not <thread.h> . See section 7.26 of the N1570 draft. Most of the C standard library, including stdio for example, is not included in the gcc distribution. Instead, gcc depends on whatever runtime library is provided by the operating system. That generally includes both the headers (like <threads.h> ) and the actual code that implements the library. For most Linux systems (or GNU/Linux if you prefer), the library is GNU's glibc; for other systems it will be something else. So the real question is probably when glibc, or whichever C library you're using, will support C11's threading features. glibc adds support for C11 threads in version 2.28. Ubuntu 18.04.1 LTS system currently still uses glibc 2.27. Again, this applies only to implementations using GNU libc, not to all gcc-based implementations. Mentioned by WorldSEnder in a comment. UPDATE: Ubuntu 18.10 (not an LTS (Long Term Su...

Can C++ Raise An Error When Std Array Initialization Is Too Small?

Answer : You can use std::make_array or something like it to cause the types to differ std::array<int, 6> = std::make_array(4,3,2); gives this error in gcc: <source>:30:53: error: conversion from 'array<[...],3>' to non-scalar type 'array<[...],6>' requested You can create your own layer of abstraction that complains when you don't pass the exact same number of arguments for initialization. template <std::size_t N, class ...Args> auto createArray(Args&&... values) { static_assert(sizeof...(values) == N); using First = std::tuple_element_t<0, std::tuple<Args...>>; return std::array<First, N>{values...}; } To be invoked as auto ok = createArray<6>(4, 3, 2, 1, 0, -1); auto notOk = createArray<6>(4, 3, 2}; Instead of writing your own createArray method you can use the https://en.cppreference.com/w/cpp/experimental/make_array if your compiler supports it. #include ...

Can't Find File Executable In Your Configured Search Path For Gnc Gcc Compiler

Answer : I'm guessing you've installed Code::Blocks but not installed or set up GCC yet. I'm assuming you're on Windows, based on your comments about Visual Studio; if you're on a different platform, the steps for setting up GCC should be similar but not identical. First you'll need to download GCC. There are lots and lots of different builds; personally, I use the 64-bit build of TDM-GCC. The setup for this might be a bit more complex than you'd care for, so you can go for the 32-bit version or just grab a preconfigured Code::Blocks/TDM-GCC setup here. Once your setup is done, go ahead and launch Code::Blocks. You don't need to create a project or write any code yet; we're just here to set stuff up or double-check your setup, depending on how you opted to install GCC. Go into the Settings menu, then select Global compiler settings in the sidebar, and select the Toolchain executables tab. Make sure the Compiler's installation director...