Click here to Skip to main content
15,891,633 members
Everything / GCC

GCC

GCC

Great Reads

by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.
by altomaltes
This code calculates square root of an integer on a few assembler code lines.
by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
by Mikhail Semenov
This article proposes a mapping algorithm, called Segmented Map, which is almost as fast as Flat Map is random access and enumeration of elements and close to std::map in insertion of elements.

Latest Articles

by ToughDev
Retro68 GCC-based SDK for 68K Mac
by ToughDev
How to build Wireshark 1.12.5 static binaries for CentOS 5
by Steffen Ploetz
Is LINQ the right technology for processing large amounts of data in runtime-relevant environments?
by Mikhail Semenov
This article proposes a mapping algorithm, called Segmented Map, which is almost as fast as Flat Map is random access and enumeration of elements and close to std::map in insertion of elements.

All Articles

Sort by Updated

GCC 

27 Dec 2023 by Richard MacCutchan
See B2 User Manual - 1.84.0[^].
27 Dec 2023 by Member 15872449
I am using centos 5.11 with gcc-4.6.3 support ,I need to build boost thread library(version 1.82) using the same gcc without upgrading . What I have tried: The commands I used are ./bootstrap.sh ./b2 But running the bootstrap command I am...
23 Jul 2023 by honey the codewitch
I'm trying to get my C++ project to compile under ZephyrOS. It doesn't use many of the standard includes, but it uses and my build system is such that it's not finding it. It uses GCC and not G++ and I was wondering if that might have...
23 Jul 2023 by honey the codewitch
To fix, add the following to prj.cfg CONFIG_CPP=y Then it works.
7 May 2023 by ToughDev
Retro68 GCC-based SDK for 68K Mac
7 May 2023 by ToughDev
How to build Wireshark 1.12.5 static binaries for CentOS 5
15 Nov 2022 by Steffen Ploetz
Is LINQ the right technology for processing large amounts of data in runtime-relevant environments?
18 Sep 2022 by Mikhail Semenov
This article proposes a mapping algorithm, called Segmented Map, which is almost as fast as Flat Map is random access and enumeration of elements and close to std::map in insertion of elements.
10 Sep 2022 by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.
22 Jun 2022 by reverser69
hi after searching for a month or two, I finally found out the solution: in x86 code, APIs must be prefixed with underscore and called by their decorated name. e.ge i must call like: calll _MessageBoxA@16 16 being the number of bytes of the...
21 Jun 2022 by reverser69
hi all i want to learn asm inlining using codeblocks+GCC(MinGW32) and i came across this problem. this is my code: #include #include #include char * msg = "Hello, World!\n"; char * wMsg = "Content of the...
3 Jun 2022 by srtmdem
I am trying to use "sbas_parallel.c" code in ubuntu 18.04, i install a "gcc" compiler and insert the written row below ; "gcc -fopenmp -w sbas_parallel.c -I/usr/local/include/gmt -I/usr/local/GMTSAR/gmtsar -I/usr/local/include...
3 Jun 2022 by k5054
You'll note that the include directive is surrounded by double quotes. This indicates that the file in question should be either in the current directory, or perhaps in a directory on the include path, (the arguments to the -I flags). Looking...
8 Dec 2021 by honey the codewitch
This is complicated so bear with me. I have a very performance sensitive codepath I'm working on, for low level IO comms with LCD displays, so there's a lot of data I have to move quickly. I am working with an offering called TFT_eSPI GitHub -...
7 Dec 2021 by Stefan_Lang
I never tried that myself just for this purpose, but have you considered wrapping the code in question into a template function? If I'm not mistaken that should force it to be inline. E. g.: template void address_window_internal(T...
7 Dec 2021 by honey the codewitch
Overall I must optimize my code for size, due to targeting IoT devices which have small amounts of SRAM with which to code for execution, and which have small program flash sizes, but there are some situations where I need trivial functions to be...
6 Dec 2021 by k5054
Have you tried the always_inline attribute? See the attribute specification documentation over at cppreference.com[^] That requires C++-11, so will hopefully be available for your G++ tool chain. Also see Optimize Options (Using the GNU Compiler...
24 Aug 2021 by ilostmyid2
When making the following code: #include typedef struct { } obj; void f1(obj **ppo) {} void f2(const obj **ppo) {} void f3(obj *const *ppo) {} void f4(obj **const ppo) {} void f5(const obj *const *ppo) {} void f6(const obj...
30 Jul 2021 by Atul Shreewastav
1 6 10 13 15 2 7 11 14 3 8 12 4 9 5 This is how the output should look like What I have tried: I tried to find a specific pattern that follows in the rows and columns and found: 1....
30 Jul 2021 by OriginalGriff
Think of it this way: assuming you have to print this in a console, then you need to print it as complete rows (or it gets complex: you need to create a 2D array, fill it, and then print that. While that is actually pretty simple to to, if you...
27 May 2021 by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
24 Apr 2021 by Ahmad Qassym
1) gcc -c file.c -o file.o 2) gcc file.c -o file please if u gonna to answer the question ,try to give an simple answer as much as possible! What I have tried: ......................................................
24 Apr 2021 by Aghast (nj)
Command (1) compiles the .c file to a .o (object) file, then stops. Command (2) compiles the .c file to an object file, then links the object file with the C standard library to produce an executable file named file. Both commands drop their...
24 Apr 2021 by Dave Kreskowiak
-c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file. By default, the object file name for a source file is made by replacing...
22 Mar 2021 by Rick York
There are several errors in this code. Here's one : MemMgr::InsertBlock(void* block) { if(sizeof(block) > MAX) throw runtime_error("Blocksize too big"); if(_blocks.size() > MAX) throw runtime_error("Out of room"); ...
22 Mar 2021 by Tim ONeil
I have defined a pretty simple class that I'd like to manage an array of blocks of data, arrays of 256 bytes each, with a max number of 256 blocks. I'm using a std list to hold the arrays. For testing I'm creating a an array of same, memsetting...
22 Mar 2021 by Greg Utas
It's hard to debug just looking at a sketch, but void* is the size of a pointer. So when you index _mempool, you're going to be incrementing by the size of a pointer (32 or 64 bits), not a byte. I would suggest trying uint8_t* instead of void*....
9 Feb 2021 by ilostmyid2
I'm going to implement 'friend' classes in C! For this I need not to allow all sources to include specific header file. One method is to define the whole child class in the parent class. This is not a good idea, because the volume of the parent...
9 Feb 2021 by k5054
It's not exactly clear what you are trying to do. It sounds like you don't want to use //myHeader.hpp #ifndef MYHEADER_H #define MYHEADER_H /* ... header info */ #endif // MY_HEADER_H If that's the case, maybe #pragma once is what you're...
11 Dec 2020 by honey the codewitch
Apparently I'm getting rusty. I need to find a way to have an unordered_map reference a struct using just its forward declaration, but I want STL to handle allocation and cleanup like normal. See the code for a concrete example of what I want. ...
11 Dec 2020 by steveb
Forward declarations work only for pointers and references. Depending which compiler you using, the "map_value" is an incomplete type at the point where you declared it inside the struct map_value body. I beleive it probably should be: struct...
10 Dec 2020 by honey the codewitch
Try mv.value.insert(std::make_pair("test",std::unique_ptr(pmv2))). std::make_unique is really simply... dynamic allocation (with new) following by constructing a std::unique_ptr to hold the pointer. The constructor is explicit so it...
3 Dec 2020 by Yuancai (Charlie) Ye
C++, C++20 Coroutine, Awaitable Object, co_await, Cross Platform Development and Non-blocking Socket Communication
29 Oct 2020 by Gautam Naresh
#include using namespace std; #define getName(VariableName) # VariableName int print(int num) { std::cout"
28 Oct 2020 by Rick York
You are calling the macro like this : getName(num), so it can not possibly display mynum. I had a similar problem and I did something like this : #define printValue( val ) print( val, # val ) int print( int num, const char * name ) { ...
9 Oct 2020 by User 14926697
I want to connect two OS with each other and I'm using this code: #include #include #include #include #include #include #include #include #include...
9 Oct 2020 by OriginalGriff
Probably it's your compiler / linker command line. Have a look at this, and compare what you use with the solution there: c++ - MinGW linker error: winsock - Stack Overflow[^]
15 Sep 2020 by Stefan_Lang
First of all, iostream is the least of your problems. By far! I'm not quite sure what your teacher wanted to achieve with this task. If your programming skills aren't advanced enough to immediately spot and fix at least a dozen errors before...
15 Sep 2020 by Member 14935473
initially our teacher gave this as an example. told us to check to see if it works, internet was slow so we ended the class, but i kept working on it #include #include using namespace std; class structure{ typedef...
10 Sep 2020 by CPallini
You code looks like a mix of C and C++ programming languages. Typically, the C programmer writes #include typedef struct { char firstname[20]; char lastname[20]; int age; } student_info; int main () { student_info student[]...
16 Jul 2020 by Pilallamarri chandhu
Consider the following code: #include class Intersect { public: static bool overlap(std::string polygonA, std::string polygonB); }; bool Intersect::overlap(std::string polygonA, std::string polygonB) { // implementation goes here return...
16 Jul 2020 by Stefan_Lang
Just looking at your code, there are two issues: 1. In your second for loop, you are referencing ss (twice), where you should use ss1 instead 2. While you did use loops to interpret the string of coordinates, you did not use loops to calculate...
15 Jul 2020 by KarstenK
You better implement a polygon class which takes the string as input. In the constructor or better parse function use must convert the string numbers into numbers with some function as atoi because math with strings is nonsense . This is also...
29 Feb 2020 by Oscar-Tark
A basic formatted string exploit shows you how small errors in programming with the printf function can be a lethal weapon for hackers looking to compromise a system.
26 Jan 2020 by Richard MacCutchan
Using the GNU Compiler Collection (GCC): Link Options[^]
26 Jan 2020 by Vaclav_
My goal is to have one place to edit common class. I have build standard Linux x.a library and it compiles. The "problem" - the common class uses another library and the original "project" was linked to such library. I have included the required headers, now I need help to figure out how to...
26 Jan 2020 by CPallini
Simply pass the filename (without -l) of the required library to gcc.
4 Jan 2020 by heilokchow
benchmark tool to test whether your math library is set up properly
3 Dec 2019 by thoughts-on-coding
Matrices are a key concept in solving linear equation systems. Efficient implementations of matrices are not only considering computation complexity but also space complexity of the matrix data.
5 Nov 2019 by Stefan_Lang
I strongly suspect this is a bug in the compiler's code optimization: M isn't read by the program, so the compiler will try to eliminate code referring to it - maybe it messed up this optimization because the statement cin>>N>>M internally translates into a nested function call:...
5 Nov 2019 by Shubham Avasthi
I was working on a C++ code, which for some unknown reason, does not terminate by Ctrl + C. The below code is a reduced version of the code I was working on and it has the same issue. Moreover, if I don't take an input for M (remove '>>M') or remove vector a(n) or initialize the size of vector...
5 Nov 2019 by RickZeeland
Might be a debugger issue, see: Workaround for GDB Ctrl-C Interrupt | MinGW[^]
5 Nov 2019 by CPallini
On my Linux box (Ubuntu 18), the following program #include #include using namespace std; int main() { int N,M; cin>>N>>M; vector a(N); } compiled with the g++ -O3 -std=c++14 (g++ 7.4.0) behaves as espected.
27 Sep 2019 by RickZeeland
Here is an interesting CodeProject example: RGF: A Save/Open Dialog Box with Cloud Capabilities[^] You can also take a look at the Google Cloud Client Library for C++ GitHub - googleapis/google-cloud-cpp: Google Cloud Client Library for C++[^] Another option is the C++ REST SDK: GitHub -...
27 Sep 2019 by Proyash Paban Sarma Borah
all said in the question. i am fairly new to coding please explain in simple words...help expected What I have tried: Dont' have a clue how to set up so i wasn't able to. i read about fout() being able to acess network servers but i didn't saw any code or understandable instruction.
9 Jun 2019 by cassert24
Template code for basic reflection functionalities (e.g., dynamic casting, instance type comparison, class name) with C#-like singular inheritance rule (a.k.a, one-base-multiple-interface rule)
5 Jun 2019 by altomaltes
This code calculates square root of an integer on a few assembler code lines.
26 Mar 2019 by thoughts-on-coding
Introduction into an Automated C++ Build Setup with Jenkins and CMake
14 Mar 2019 by Martin Vorbrodt
Memory barriers and thread synchronization
6 Nov 2018 by z3ngew
Hello everyone, I am building a code library in c to drive a keypad using atmega microcontroller, for that i have created 2 files keypad.h and keypad.c I am using GCC C compiler when i try to declare a static variable in .h file and then define it in .c file, as follow; .h file static char...
6 Nov 2018 by Richard MacCutchan
You should not be defining them in the header file if they are static, just in the .cpp file. If you are trying to create global variables then you should declare them extern in the header, and give them a value in one .cpp file only, like: // header.h extern int variable; extern int...
6 Nov 2018 by CPallini
You should declare your variable extern in the header and define it in the source file (without the static keywork: static in source file provides internal linkage). See, for instance: Internal linkage with static keyword in C - Stack Overflow[^].
15 Sep 2018 by Patrice T
Quote: Flight search you work as a software developer for a major airline This smells like 1 of those challenge sites contests. The same question have been asked already today, you should team with your class/contest mates. All the interest of those contests is to know if you can solve it or...
17 Aug 2018 by Member 13952559
My Makefile: HEADERS = headers.h macros.h main.h socket.h main.o : main.c main.h cc -c main.c socket.o : socket.c headers.h macros.h cc -c socket.c main.c #include "main.h" main() { printf("%s\n","Connect_Socket Start"); Connect_Socket(IP_ADDRESS, PORT); printf("%s\n","Connect_Socket...
17 Aug 2018 by Jochen Arndt
Executing make will build the target according to the specifed rules. But it will not execute the created application. To do that after a successful build do it like you have done with manually compiling: type the name of the executable at the shell prompt ./mqtt_c8y
17 Aug 2018 by OriginalGriff
Ata guess - and without your computer to hand that's all it can be - you don't get the output because the app is too busy connecting the socket to update the display. Try adding a user input after the printf and see what happens.
6 Jul 2018 by raddevus
Arduino: just say no to shields
30 Jun 2018 by Member 13056292
in linux to compile cpp: 1) use g++ channelassignment.cpp, on successful compilation, ./a.out will execute. 2) g++ -o channelassignment channelassignment.cpp to get an executable of the same name i.e ./channelassignment hope it helps!
30 Jun 2018 by Shah Rukh Qasim
I want to compile a file in linux. When I compile it in MS visual studio (windows), it works quite fine but when I try to compile in linux by issuing command:"gcc channelassignment.cpp" I get following errors.../tmp/ccLvTU1V.o: In function...
11 May 2018 by OriginalGriff
Use the Process class to execute gcc: Process Class (System.Diagnostics)[^] Be aware: if you "randomly" run applications you are given as source, you are opening your whole machine up to whatever the app writer chooses to do. I would STRONGLY recommend that you look at using a VM if you value...
11 May 2018 by Member 13823039
I am trying to create a c++ console application judge system in C# for myself and a few friends. The user should select a cpp file, a folder with tests(an input file and an output file). The program should compile the cpp file(the user should have gcc compiler installed), execute it for every...
8 Mar 2018 by Alex the Green Apple
C library defining string type and string manipulation functions
28 Feb 2018 by Member 13376650
I use windows 10, and I think I already installed gcc 4.9.2 with codeblocks IDE automatically. This is the result of gcc --version command on CMD: gcc (tdm-1) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO...
28 Feb 2018 by phil.o
You can have both. Nothing prevents you from having several versions of the compiler installed.
22 Feb 2018 by Gabriel Leonte
well. i run this : ../configure \ --target=$LFS_TGT \ --prefix=/tools \ --with-glibc-version=2.11 \ --with-sysroot=$LFS \ ...
22 Feb 2018 by Jochen Arndt
It is difficult to answer that without knowing what you are tyring to build and on witch system with which compiler. As suggested in the output you should have a look at the config.log file. That should contain error messages from the started tools (the C compiler) which might indicate what...
20 Dec 2017 by Member 13587774
#include int main() { int a[3]={1,2,3}; int *p; p=&a+2; *p=50; printf("p = %d\n",p); printf("*p = %u\n",*p); printf("z = %u\n",&a+1); printf("y = %u\n",*(&a+1)); } What I have tried: I am getting the output on particular memory location only by using double pointer. Why...
20 Dec 2017 by Jochen Arndt
The compiler shows warning: assignment from incompatible pointer type for the line p=&a+2; That is because a is an array and therefore already an int* pointer. So it must be p = a + 2; // or p = &a[2]; and similar in the printf calls.
20 Dec 2017 by CPallini
Always compile with the -Wall switch. As matter of fact GCC warns on Quote: p=&a+2; That shoud be instead p = a + 2; Try #include int main() { int a[3]={1,2,3}; int *p; p=(a+2); *p=50; int n=0; for (n=0; n
18 Sep 2017 by Shmuel Safonov
Creation a numeric library that calculates with quadruple floating-point precision and used from MSVC C/C++ code
27 Apr 2017 by Richard MacCutchan
You already posted this at Importing OpenSource Projects in CodeLite Ubuntu - - Uncategorised posts - Discussion Boards[^]. You have been a member here long enough to know not to cross post the same question in multiple forums.
20 Apr 2017 by Neonbird
I am using Cygwin to link my kernel written in c. I successfully create two object files, one from nasm and other with gcc. How do i link it? when i tried, it give me output: ld: cannot perform PE operations on non-PE file format. What I have tried: I tried to link with ld -o...
4 Apr 2017 by Patrice T
Quote: but im getting errors while submitting Which error messages ? Assuming you have a C compiler, you should learn how to use a debugger, it is an incredible tool. When you don't understand what your code is doing or why it does what it does, the answer is debugger. Use the debugger to see...
3 Apr 2017 by Patrice T
int array[argc] This not how you should allocate memory to dynamic variable. Read about "dynamic memory allocation" in C. If you can run the program o, your computer, use the debugger to see what happen. Advice: learn to indent properly your code, it helps to read it. #include...
3 Apr 2017 by Member 13095321
Your program should take as input a text file which contains numbers to be sorted and it should output a text file containing the sorted sequence and also output at each round of insertion sort. Both input and output files should be passed as command line arguments to your program as given in...
3 Apr 2017 by OriginalGriff
A Segmentation fault occurs when you try to use an invalid pointer, or on some systems try to access an array element that doesn't exist - it depends on the compiler what errors it detects. I would say that the first problem is that you are ignoring the instructions: Quote: Both input and...
3 Apr 2017 by Jochen Arndt
It looks like the above status message is generated by a test tool run by the site to which you are uploading it for verification. The tool seems to check if your program generates an output file and assumes some kind of error if no output file is generated. So have again a look at the...
31 Mar 2017 by Member 13095321
i need to write a program to sort command line arguments (Numbers).What I have tried:#include#includeint main(int argc, char *argv[]){ int i, j, t, n, pos, a[100]; n = argc - 1; printf("\nNumber of elements in the input array is : %d\n",...
31 Mar 2017 by KarstenK
There are different sorting algorhitms, so this tutorial at cprogramming gives you a fine lesson about sorting. tip: use Google
30 Mar 2017 by Member 13095321
it's a pretty easy question, but im getting errors while submittingQuestion:Write a function isPrime(n) which outputs 1 or 0 if n is prime or not, respectively. Use this function in a program that takes a starting integer (s) and ending integer (e) as input and outputs 1 every time a prime...
30 Mar 2017 by Mehedi Shams
Hi Member 13095321,There is a mistake in this line:for(i=2; i
1 Nov 2016 by Philippe Mori
The first problem with your code is that identifier that begin are reserved for the system. In your case, you use the well known macro _T as a parameter for your template.Unicode Programming Summary[^]The next problem with your code is inconsistent use of int and size_t for the size....
26 Oct 2016 by «_Superman_»
These keywords were used in the old days when memory was segmented (Code Segment, Data Segment, Stack Segment etc.).With the current Virtual Memory Model, these keywords are of no importance.But to answer your question, local variable all reside in a single segment (Stack) and hence the...
26 Oct 2016 by KarstenK
This are old keyword for compilers, to enhance the pointer address model. A good explanation is in the cplusplus-forum.In today programming world these keywords arent needed. With a little Google you would had found the answer in the last year. Like the explanation of the far pointer in...