Questions tagged [gcc]
GCC is the GNU Compiler Collection. It's the de facto standard C compiler on Linux and supports many other languages and platforms as well.
42 questions
0
votes
0
answers
161
views
How To Share Code Between Assembly Files In A Modular Way
Recently, I started learning Arm64 assembly. The assembler I'm using is the GNU Assembler (GAS). The version of GAS I'm using is GNU assembler (GNU Binutils for Ubuntu) 2.42.
I want to make my code ...
-2
votes
1
answer
1k
views
In C++ and GCC on Linux, is it possible to allocate memory to your swap space instead of your RAM?
I have a large hash, around 6 gigabytes that I load into memory. On my current laptop that I develop from, it really does a number on my system, causing massive amounts of lag while I try to go about ...
8
votes
1
answer
16k
views
Difference between direct and indirect function() calls
I am curious about the Difference between direct and indirect function() calls
Could anyone help in the diff analysis ?
The c source code could be found at subroutine_direct.c and ...
2
votes
3
answers
3k
views
How to prevent 'global variables' in a big project?
With 'global variables', I mean
Variables on namespace level
Static data members in classes
Static variables in functions
In a big C++ project I would like to have a mechanism (like a compiler option) ...
0
votes
0
answers
143
views
Results of testing different compiler optimizations of GNU GCC are confusing
I tested out a few different compiler optimizations on GNU GCC, in the CodeBlocks IDE. With each different optimization I ran the same test: I let my program try to build as big of a tree as it could ...
0
votes
0
answers
114
views
Cycle accuracy through the use of a microtable for an 8 bit CPU emulation?
I'm in the process of writing a 8 bit cpu emulator and currently have a jump table for different opcodes. I want to move this over to be cycle accurate and was wondering what the best approach would ...
-1
votes
2
answers
965
views
How to port gcnew and gcroot from Visual C++ to gcc [closed]
I have the task to port some code from Visual C++ to gcc.
Some calls are gcnew and gcroot to handle managed code inside cpp module.
How can these calls be ported to gcc in a fashionable way?
11
votes
2
answers
19k
views
Why C allows multiple global declarations of the same variable but NOT multiple local declarations?
I noticed that if I declare a global variable multiple times the compiler does not even output a warning.
However if I declare a local variable in a function multiple times, for example, the gcc ...
20
votes
2
answers
18k
views
Why glibc is maintained separately from GCC?
GCC is the C compiler. Glibc is the C library. However, isn't it an absolute necessity for a compiler and the standard library bundled together as a C implementation?
For example, the C library ...
1
vote
1
answer
2k
views
Need info on malloc trace
When I try the below code I am not clearly able to analyze malloc api internal calls.What I am not clear is about the system call mmap is called only once for 2 or more malloc calls.If I am assigning ...
4
votes
3
answers
7k
views
How can I tell what standard my C is in?
Okies, totally newbie question here. I can read the code, mimic the code and understand the basics to be deadly. But, I never really took the time to understand what ANSI C really meant. I just look ...
1
vote
1
answer
2k
views
What does using pointer in Linux kernel imply?
So far I was under the perspective that while working in the kernel code, working with memory implies working with long integers and not pointers because dereferencing pointers shouldn't be done in ...
13
votes
3
answers
12k
views
Isn't there a chicken-and-egg issue since GCC is written in C++ itself?
Since 4.8 release, the C++ compiler GCC (the G++ part of it) is written not in C anymore, but in C++ itself. I have a hypothetical question on this.
I wonder how to compile the C++ code of GCC on a ...
3
votes
2
answers
2k
views
How to avoid long call chains?
I have a hierarchy of objects, mostly connected by composition. I.e. (not showing the class methods for readability):
class A {}
class B {A a;}
class C {B b;}
etc...
class Z {Y y;}
class Z provides ...
6
votes
2
answers
4k
views
In which stage of compilation is "typedef" resolved by the compiler?
There are different stages of compilation
Such as
Preprocessing stage
Syntax analysis
Semantic analysis
Intermediate Code generation
Machine Code generation
Optimization
Linking
My question here is ...
5
votes
2
answers
542
views
Larger Code is Still Faster
When compiling C code with gcc, there are compiler optimizations, some that limit code size and others create fast code.
From the -S flag, I see that the -O2/03 generates more assembly than the -Os ...
31
votes
3
answers
17k
views
Is GCC dying without threads support on Windows? [closed]
I need some opinion. GCC was always a very good compiler, but recently it is losing "appeal".
I have just found that on Windows GCC does not have std::thread support, forcing Windows users to use ...
4
votes
2
answers
1k
views
How do .so files avoid problems associated with passing header-only templates like MS dll files have?
Based on the discussion around this question. I'd like to know how .so files/the ELF format/the gcc toolchain avoid problems passing classes defined purely in header files (like the std library). ...
290
votes
7
answers
453k
views
How to write a very basic compiler
Advanced compilers like gcc compile code into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of the code ...
1
vote
2
answers
900
views
GCC: assembly listing for IA64 without an Itanium machine
I need to try the following thing: I would like to compile some simple C code samples and see the assembly listing generated by GCC for IA64 architecture, i.e. I just want to run GCC with the -S ...
23
votes
5
answers
22k
views
Whether to use -pedantic flag in g++ or not?
I'm learning C++ and I'm using g++ on Linux for practicing.
I want to know if people working as programmers use g++ -pedantic flag and also its importance in real world.
What about other compilers, ...