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
114
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 ...
-3
votes
1
answer
185
views
What does the filename "gmon.out" stand for?
The GNU compiler toolset has a profiler "gprof" for performance analysis of C++ programs. With the -pg switch, the gcc compiler will make executables that write a data file, "gmon.out&...
-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 ...
1
vote
2
answers
1k
views
Logically, is there a reason why ++i++ can not be a valid expression?
I had to increment my integer twice in a loop, so I thought I would try and be clever:
for (int i = 0; !sl.isEmpty(); ++i++) { ... }
++i++ however is not an assignable expression, at least in GCC.
...
8
votes
1
answer
15k
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 ...
1
vote
3
answers
2k
views
Does the gcc optimize out local arrays the same way it would optimize out a local variable?
If I write this code in a function:
void func(void)
{
int x = 0;
int y = 3724832+x;
}
It would (probably) optimize the variable y out because it isn't being used. Even if I'm wrong about ...
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 ...
3
votes
4
answers
2k
views
GCC or Clang to output bytecode for a VM?
Long story short, I wanted to use C as a scripting language and in a portable manner so I created a register-based, JITless VM to accomplish this.
I've formalized the VM's ISA, script file format, ...
0
votes
0
answers
133
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
1
answer
108
views
When is it a good idea to test a build with both clang and gcc?
I am peeking through the code of torsocks where as you'll notice, the .travis.yml file instructs Travis CI to test against both clang and gcc.
compiler:
- clang
- gcc
I'm still learning and ...
0
votes
0
answers
101
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 ...
63
votes
9
answers
14k
views
Novice programmer(s) frustrated by lack of a glossary of compiler errors
A friend of my family asked me for a bit of help as he learns to program (in the C language). As we were talking, he expressed frustration about having a hard time understanding the error messages his ...
-1
votes
2
answers
913
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?
2
votes
1
answer
98
views
Does an explicit temporary of an integral type qualify as an integral constant expression?
In the following code, int() is an explicit type conversion.
#include <iostream>
int main()
{
void* ptr = int();
return 0;
}
Clang Compiler:
source_file.cpp:5:11: error: cannot ...
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 ...
-1
votes
1
answer
2k
views
Why is it possible to access an array out of bounds with negative indexes much further than with positive indexes?
I have written two small programs in which I declare a very small array.
Then I try to access values out of bounds.
The interesting thing I noticed that when I try to decrement the index I can ...
19
votes
2
answers
17k
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 ...
8
votes
2
answers
853
views
Is it wise to use Clang for personal code analysis in a project that builds with gcc?
I started to work on several C projects that are building using gcc. I believe this choice was made for several reasons:
Had to cross-compile for arm very early on (I think).
Performance is the first ...
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 ...
1
vote
1
answer
151
views
Cross compiling: Share compile steps between different target platforms?
For a C project, I'm upgrading my build process from
MingGW-GCC / make and Android Studio under Windows (2 separate processes)
to
Clang / CMake under Debian 8, using wclang and wine to compile and ...
4
votes
3
answers
5k
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 ...
2
votes
3
answers
3k
views
When does gcc not work on Windows [closed]
Everyone (who knows C) always tells me to be careful when using gcc to compile on Windows, yet they never actually tell me what the compatibility issues are. I'm left to believe that gcc is just 'not ...
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 ...
2
votes
1
answer
623
views
Why isn't the isa pointer hardwired in Objective-C classes?
I've been studying the Objective-C runtime for some years, and even hacked libobjc a little bit (both Apple's and GNUStep's), and I've been wondering about a design decision on the compilers.
Every ...
13
votes
3
answers
11k
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 ...
10
votes
1
answer
3k
views
Why does GCC use AT&T syntax by default?
I think title says it all :)
Is there any particular practical reason (I guess it's mostly historic, but I'm unable to find it on my own) why GCC uses AT&T/GAS syntax?
Note: I know this is just ...
3
votes
2
answers
1k
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 ...
-2
votes
1
answer
2k
views
Illustrate Meaning of : gcc -g programName.c
To debug a C program using gdb effectively it is required to compile it first using the command:
gcc -g programName.c
otherwise on using simply
gcc programName.c
and running we are unable to ...
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 ...
0
votes
1
answer
814
views
Macro guard in Objective-C
I have noticed that many famous libraries written in Objective-C (eg. AFNetworking) use the macro guard inside their header files.
Im aware that the #import directive, which works exactly like #...
5
votes
2
answers
527
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 ...
3
votes
1
answer
4k
views
register variable in C and C++
I know the concept of register variable and it's use cases but there are few questions in my mind based on what I have tried.
I cannot access the address of a register variable in C though I can do ...
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 ...
12
votes
6
answers
2k
views
Is there a way to use gcc as a library?
Anyone knows a solution that works something like this:
#include <stdio.h>
#include <gcc.h> /* This .h is what I'm looking for. */
int main (void) {
/* variables declaration (...) */
...
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). ...
9
votes
2
answers
3k
views
Questions about linking libraries in C
I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when ...
290
votes
7
answers
444k
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 ...
7
votes
2
answers
3k
views
Need help eliminating dead code paths and variables from C source code
I have a legacy C code on my hands, and I am given the task to filter dead/unused symbols and paths from it. Over the time there were many insertions and deletions, causing lots of unused symbols. I ...
1
vote
2
answers
884
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 ...
7
votes
3
answers
2k
views
Does using GCC specific builtins qualify as incorporation within a project?
I understand that linking to a program licensed under the GPL requires that you release the source of your program under the GPL as well, while the LGPL does not require this. The terminology of the (...
23
votes
5
answers
21k
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, ...
26
votes
4
answers
13k
views
GCC vs clang/LLVM -- pros and cons of each [closed]
What are the pros and cons of GCC vs clang/LLVM?