Click here to Skip to main content
15,891,597 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 

14 Jan 2012 by 01.mandar
i have set up target fs on /home/myself/filesys/bin..etc//GCC compile:host $ arm_v5t_le-gcc hello.c -o helloRun:target $ cd /opt/hellotarget $./helloi have installed opencv2.3 on host ubuntu machine now i want opencv to be ported to DM6446 so i follow 1 uncompress opencv2.3...
6 Apr 2013 by 125Azazelo
Hi i have beginner question how to make .so and .dll from .cpp in Linux?I have simple project no thread , 2 .h files ,and 2 .cpp files.
14 Apr 2012 by Aescleal
(really old question, but there's no solution and it might be useful for other people later)If your server is single threaded (which I doubt) then you can use strtok to slice chunks off the string using the ? and @ characters as delimeters.If you're writing a multithreaded server then on...
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 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: ......................................................
16 Jan 2013 by Ajay Vijayvargiya
Covering the nitty-gritties of C++ templates.
3 Dec 2015 by Albert Holguin
If you really named your library Dll.dll, that's a horrible name! Aside from that, I'd check what Richard suggested above (make sure there's a path to the library or its in a good default location) and also check with a tool like Dependency Walker[^] to make sure there isn't some other...
8 Mar 2018 by Alex the Green Apple
C library defining string type and string manipulation functions
5 Jun 2019 by altomaltes
This code calculates square root of an integer on a few assembler code lines.
12 Jan 2012 by Andreas Gieriet
You need to give names to all union members.In your code, the sub-unions have no name -> no declaration warning.With the extension, the anonymous sub-unions seem to introduce their members directly into the current union. This results in having the members raw, etc. declared twice.Your...
3 Sep 2012 by Andreas Gieriet
You ask for a C solution.I would solve it in a bash script using kill[^] and mail[^].For programming in C, use kill[^] and fall back to the mail command line tool to send the notification (via system[^]).See also wikipedia[^] for an overview on kill and wikipedia[^] on unix mail...
19 Oct 2012 by Arun Kumar K S
Hi, I checkout and recompiled the source of Songbird player on windows it compiled and get a new executable.Building Songbird[^] I am stuck with from where I can change the name and icon of executable in Songbird source ?please help me any one knows about this.....
10 Dec 2012 by Arun Kumar K S
I created one application for Ubuntu that reads data from serial port and save to a file. But when I run the application that wont work. One permission denied Issue. That is working when I run from terminal using sudo ./AppName an type the password after that. How I can run and work it...
5 May 2014 by Arun Kumar K S
I am trying to create an i2c communication in raspbery Pi(debian wheezy) using Qt creator with rpi-hw library. I successfully compiled and installed the rpi-hw library in my linux system. But when I try to include this in my Qt. Got the following...
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....
27 Aug 2014 by Bartlomiej Filipek
Several issues related to smart pointers that are worth knowing.
16 May 2014 by Bartlomiej Filipek
Description of the implementation of my particle container
8 Jun 2014 by Bartlomiej Filipek
Flexible Particle System - Updaters
3 Jan 2016 by Bartlomiej Filipek
Maybe I’ll be boring with this note, but again I need to write that this was another good year for C++! Read my report from 2015.
11 Jan 2016 by Bartlomiej Filipek
Description of a simple performance timer that can be used to profile cpp code in your app
23 Oct 2013 by Captain Price
Try the ICU library:http://site.icu-project.org/[^]
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)
17 Nov 2011 by coffeenet
Hi,I am trying to gprof my program. I want a line-by-line profiling.However, I can't seem to get the syntax write. I am using "make" and not "gcc" so please help only with suggestions that fit make. I wouldbe very grateful if you can give me the full "make" syntax.Based on this...
5 Dec 2012 by coffeenet
Hi,I have successfully cross-compiled a program on an x86-64 machine. However, when I try to run on my target machine sh4a, I get the following error:./ioq3ded.sh4a: /lib/libc.so.6: version `GLIBC_2.11' not found (required by ./ioq3ded.sh4a)The details of the two machines are as...
8 Nov 2012 by CPallini
The following program:// foo.hnamespace preprocessing{ namespace generaldef { const int BASE = 0; }}// foo.cpp#include "foo.h"#include using namespace std;int main(){ cout
24 Dec 2012 by CPallini
You usually don't pass the whole name of the library (that is complete with its extension), for instance when you link with librt you don't pass directly librt.so or librt.a, but use instead the -lrt switch on command line (please note you do the same thing on Windows, for both dynamic or static...
6 Apr 2013 by CPallini
Under Linux you usually want to make .so files (Linux can't consume Windows DLLs).Here you may find a guide: "Intro to Linux Shared Libraries (How to Create Shared Libraries)"[^].
17 Jul 2014 by CPallini
A nice reading: "String overflows with scanf"[^].
19 Jun 2015 by CPallini
Sergey already gave you the correct answer, I just add an example:File a.h #ifndef __A_H__ #define __A_H__ struct A; // forward declaration of A struct B { struct A * element; }; #endif // __A_H__File b.h #ifndef __B_H__ #define __B_H__ struct B; // forward declaration of...
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
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[^].
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.
26 Jan 2020 by CPallini
Simply pass the filename (without -l) of the required library to gcc.
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[]...
25 Dec 2012 by daizhan
I have a .h file called hello.h in the include folder,a .c file in lib folder called hello.c which is the definition of functions in hello.h, and a .c file in another folder called main.c which call the functions in hello.h to do something. How can I get hello.h, hello.c and main.c files...
23 Feb 2015 by Daniel Pfeffer
Translating numerically-sensitive calculations to fixed point is a recipe for trouble and hard-to-find bugs - overflows, underflows, rounding errors, and other problems that would be masked by a floating-point implementation can easily crop up. Try to avoid it if at all possible!I've just...
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...
28 Mar 2012 by Dawood Awan
guys need help... I Am Writing a web server and I receive the data from form using the get method and i receive the dataGET /?itemnumber=1&itemquan=2&firstname=Dawood&lastname=Awam&city=Atd&cardno=123How can i Extract the Variables.. of itemnumber, itemquan,etc...
25 Sep 2013 by drlucas
I am running into a problem with the pow function in my program. The function is part of a for loop and here is the code section:for( year = 1; year
25 Sep 2013 by drlucas
Thanks. My fonts have made that suggestion look like a number 1 instead of a lower case l. It took me a few tries before I even made the connection. Thanks for the help.
11 Dec 2012 by E.F. Nijboer
You can simply give the user the rights needed. Try this:usermod -a -G dialout MY_USER_NAMEGood luck!
23 Feb 2015 by FranxCDO
** Edited **I tried changing the mentioned Jacobi algorithm to fixed point using libfixmath but I am not getting right results. What did I miss??edited Jacobi codemakefile**************************** Fisrt post ********************************************C newbie here. I...
1 Mar 2015 by FranxCDO
I want to find the eigenvalues and eigenvectors of a 3x3 matrix. My numbers are stored in fixed-point format (16.16 to be exact).Note that I don't mind much about the performance, but simply implementing an algorithm that does the job.The code below, when you build it and run it (with...
22 Feb 2018 by Gabriel Leonte
well. i run this : ../configure \ --target=$LFS_TGT \ --prefix=/tools \ --with-glibc-version=2.11 \ --with-sysroot=$LFS \ ...
17 Jul 2014 by Garth J Lancaster
char *s; doesn't allocate any memory for the scanf read - it just declares a pointer - so you need to use (for example) s = malloc(100); to get enough space for a 99 character string (plus the terminating nul) iircthe issue then is, how do you ensure your user doesn't type more than 99...
29 Oct 2020 by Gautam Naresh
#include using namespace std; #define getName(VariableName) # VariableName int print(int num) { std::cout"
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*....
27 Mar 2013 by H.Brydon
In C (and C++), the datatypes 'int' and 'enum' are partly typesafe. For example:typedef enum {E0 = 0, E1 = 1} ENUMtype_t;ENUMtype_t e = E0; // legalint i = 0; // legali = E0; // legale = 0; // legal(!)e = 1; // error(!)e = i; ...
4 Jan 2020 by heilokchow
benchmark tool to test whether your math library is set up properly
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. ...
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...
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...
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 -...
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.
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...
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...
15 Dec 2014 by javadyousefi
I want to modify next instruction before it fetches, in best answer of this question in foo function, *p points to the next instruction in main function. I want to modify content of where *p points at. For example I want to change the next instruction to a jump instruction. How to I can do...
14 Jul 2014 by Jeevan83
Hi guys, I use g cc. I want to know the address of each and every line of code.Is there any way obtaining it through dis assembling? the first column of dis assembled output seems like address to me, but I am not sure. #include #include int main() {...
17 Jul 2014 by Jeevan83
guys, whats wrong here?#include int main(){ char *s,i; printf("Enter a string: "); scanf("%s",s); for(i=0; s[i]!='\0'; ++i); printf("Length of string: %d \n",i); return 0;}output:Enter a string: jeevanLength of string: 6 Segmentation fault...
20 Jul 2014 by Jeevan83
#include#include
4 Sep 2012 by Jochen Arndt
I don't know such function. But you may write your own by listing and parsing the information from the /proc/[pid] entries in the proc file system (see man 5 proc[^]).Another solution would be execution of the ps command with the popen() function and parsing the output for the name of the...
9 Dec 2014 by Jochen Arndt
Q_COMPILER_REF_QUALIFIERS is set in qcompilerdetection.h according to the used compiler and general settings. So it should not be changed.To ignore the setting, define QT_COMPILING_QSTRING_COMPAT_CPP (as indicated by your excerpt from qstring.h). It may be also necessary to define other...
16 Nov 2015 by Jochen Arndt
So you have an executable and a shared library. The library exports symbols to be used by the executable. But you also want the library to access a symbol from the executable. This is called 'reverse dependency' and your executable must also export the symbol. This can be done by using the...
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...
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.
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...
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
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...
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...
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...
22 May 2015 by KarstenK
The mouse belongs the foreground windows, so changes work only there. You can track the mouse with TrackMouseEvent function. For every tracking cycle you must call it again!!!To get informed when your windows is activated you must handle the WM_ACTIVATE message.
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...
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
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...
27 Mar 2013 by Keanu L
#include typedef enum{red=1,blue,green}color;void set_color(color *c){ *c = blue;}int main(){ //int a = 3; //set_color(&a);//why this error? //set_color((color *)(&a));//It is right color c = red; set_color(&c); // this is right; return 0;}i...
30 Aug 2016 by LaxmikantYadav
You can use C macros __func__ and __LINE__ Please refer below link for more details,C macros __LINE__, __FILE__ and __func__[^]
17 Jul 2014 by Leo Chapiro
You have not allocate any memory for this string, the quick and dirty fix would be:#include int main(){ char s[255],i; printf("Enter a string: "); scanf("%s",s); for(i=0; s[i]!='\0'; ++i); printf("Length of string: %d \n",i); return 0;}
8 Aug 2013 by Manfred Rudolf Bihy
You're using the wrong format code %d (Scan an integer as a signed decimal number) it should be %s (Scan a character string).Read here to learn more: http://en.wikipedia.org/wiki/Scanf_format_string[^]Regards,— Manfred
26 Jul 2014 by Manikandan10
You can't do that. C++ won't allow it. Consider any other programming language that don't use these brackets. Try assembly language.
14 Mar 2019 by Martin Vorbrodt
Memory barriers and thread synchronization
30 Mar 2017 by Mehedi Shams
Hi Member 13095321,There is a mistake in this line:for(i=2; i
23 Oct 2013 by Member 10353656
hello all I am trying to convert the english language to any other local language @ run time. example in c++:- string name; cin >> name; cout
26 Jul 2014 by Member 10790454
Using gcc,how to write a program to print "hello" without using brackets('','()','{}').Thx.
19 Jun 2015 by Member 11779222
If I have the following C code:struct A{struct B* element;}struct B{struct A* element;}main(){}How do I compile it if when I declare the variable element of type "struct B*" this type wasn't defined yet?And how would I make the makefile and the header files if I had those 2...
16 Nov 2015 by Member 12144933
I am building a user defined shell where the user can dynamically load new pluggins into the shell.In some of my shared libraries I reference global variables using the keyword extern, such as the pluggin belowextern char *prompt;int setprompt(char *argv[]) { prompt =...
30 Aug 2016 by Member 12712046
Here is a project source code folder for c/c++, I want to write a small and fast tool/script to get the filename, line number, and function name for all source files . For example, I want it will output like below: ./src/a.c line 1500 call func1(); ./src/a.c line 1600 call func1();...
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 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...
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",...
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...
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...
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...
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...
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...
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...
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...
12 Apr 2012 by Member 8811020
Hello,what does it mean if something is declared like:#define __something__ ?How do i know whether i can use it in another file? I have tried some arguments from different libraries to read in my c code, but haven't figured out, on what it really depends. For instance i have the...